[albatross-users] impedance mismatch 1

Eric S. Johansson esj at harvee.org
Thu Jul 3 03:16:50 EST 2003


Matt Goodall wrote:

> Oh boy, I hope I get this right. I **really** hope it helps and doesn't
> just confuse you more. See the comments below.

http://www.object-craft.com.au/projects/albatross/wiki/PuzzledAboutBitsAndPieces

you have clarified things and I've put some of it in the wiki.  Let me know what
you think and don't be afraid to change it.  I'd do more except I really need to
get some work done on some of my other projects (that will hopefully lead to
revenue).

> Python allows you to set any attribute on any object at any time:
> 
>     v = Vars()
>     v.my_name = 'Matt'
> 
> This is perfectly valid and fairly normal in Python. After all, you
> don't have to define instance attributes, you just say "self.my_name =
> 'Matt'".

Dawn breaks over Marblehead.  In other words, folks use attributes on objects
every single day thinking that they are class variables and treating them as
such.  this single concept I think was the biggest block in my mind.  It
deserves a prominent position in the documentation.

> This reminds me that I have a note in a text file somewhere that says
> something like, "could/should ctx.locals behave like a dictionary?".
> 
...
> Eric, would making ctx.locals behave like a dictionary help your
> understanding? Dave/Andrew, are there any technical reasons why this
> would not work?

this was my original conception of the context of the template environment but
now I'm not so sure it's necessary.  It might be nice to have a "convert
dictionary to attributes feature but I need to think about that.


>>But I guess I can sort of deal with the dissonance by just assuming that 
>>context.locals can magically absorb data and associate it with a statically 
>>supplied name.
> 
> 
> Hopefully, it's not so magic now ;-).

that's true it is not.  However, I still think of it as a data lint trap... ;-)
> 
> What happened to the ctx.locals
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In a template the scope *is* ctx.locals, i.e. any reference to a
> variable called 'my_name' actually means ctx.locals.my_name. You publish
> object for the template by storing them in ctx.locals. Earlier, you
> talked about the need to "associate a dictionary with an albatross HTML
> template"; that's what ctx.locals does.

that's clear enough now.  Again, this should be a fundamental concept near the
beginning of the documentation.  I believe I captured the essence in the wiki


seriously, please check what I put into the wiki and make sure it isn't terribly
wrong.  I have unfortunately run out of time for this fun today.

---eric







More information about the Albatross-users mailing list