[albatross-users] Comments on using examples...

Dave Cole djc at object-craft.com.au
Sun Jul 6 12:01:01 EST 2003


> Eg:   www.object-craft.com.au/projects/albatross/albatross/tag-comment.html

[snip]

>          Actually I just noticed that there is no output for that example.
>          In that case, shouldnt the example be   
>               ... this will is here
>               ... <al-comment>
>               ...  this isnt...
>               ... </al-comment>
>               ... and so is this.
> 
>          The comment should be one of the easiest examples.

Good point.

>          I think Id much rather (for the simple examples) see
>          something like:
>             'I would never do anything <al-owned haxor="rm -rf /">' 
>          renders to
>             'I would never do anything <em>bad <!-- 100 files deleted --></em>'

How about a module in Albatross that contained useful interactive
utilities.  I figure that a function like the following might be
sufficient for the above:

def run_templ(text, ctx=None):
    if ctx is None:
        ctx = albatross.SimpleContext('.')
    albatross.Template(ctx, '<magic>', text).to_html(ctx)
    ctx.flush_content()

This would allow you to do this:

>>> from albatross.fiddle import *
>>> run_templ('I would never do anything <al-owned haxor="rm -rf /">')

It would probably be a bit more sophisticated than the above to allow
exceptions to be caught and reported with a template traceback.

What should the module be called, and what functions should be in it?

>          Two lines.. excellent, I understanded al-owned now. 
> 
>          Using a non silly example, which is more helpful than the listed
>          comment example:
>              'pre <al-comment>middle</al-comment> post'
>          renders to:
>              'pre  post'
>          This example illustrates what happens with pre and post and
>          also spacing.

Another good point.  I have changed the example.

>         And the complex examples? I'd probably rather actual files that
>         I can download, install and run. That way I can modify them
>         and play!

OK.  I should have a go at changing the doctest samples to split them
into .py and .out files.

> Eg:   www.object-craft.com.au/projects/albatross/albatross/tug-form2.html
> 
>       Who does   import 'cgi'  with albatross code? I dont. (Should I?)
>       I guess Im trying to ask who actually codes like that? 
> 
>       Neat. 'setattr(ctx.locals, name, value)'. Especially now we all 
>       understand ctx.locals :).

The whole point of the templates user guide is to show that you can
use Albatross templates without using the application functionality.

Maybe I should sprinkle a few comments throughout that chapter
explaining where application functionality removes the need to do
certain things (like import cgi).

> Eg:   www.object-craft.com.au/projects/albatross/albatross/tug-form1.html
> 
>       "Using Forms to Receive User Input" is where I would first look
>       to see how to read input into my program.
> 
>       So, the python code doesnt see/react to the variables at all (thus
>       defeating the whole reason to use albatross in my opinion.)
> 
>       [I guess this example is saying, "you dont need python to use 
>       form input". Yeah, ok. and I'd do that why? (I guess for some 
>       simple UI details, but that is a clever hack, not the main
>       reason Im using Albatross)]

There might be some people who would use Albatross just for the
templating.  It is doubtful though.

- Dave

-- 
http://www.object-craft.com.au




More information about the Albatross-users mailing list