[albatross-users] revisiting checkboxes..
Andrew McNamara
andrewm at object-craft.com.au
Thu Jun 26 13:36:21 EST 2003
>this leaves me with (yet another) question. How do you treat ctx.locals
>as a dictionary/array/whatever makes the easiest to programmatically
>create entries and search on them? I remember experimenting very early on
>and it didn't seem like __getattr__ and family were present. Am I just
>too sleep fogged?
>
>I've been playing around with locals.__dict__ to try and get a feel for
>what's there and at least I can see all of my spamtrap tokens but I wasn't
>able to access them as .local.xxx variables.
>
> for entry in context.locals.__dict__:
> if entry.find("token") <>-1:
> syslog.syslog(entry)
This is essentially the same thing (although it's also dumping the value of
the variables):
for attr, value in vars(ctx.locals).items():
if attr.beginswith('token'):
syslog.syslog('%s %s' % (attr, value))
My preference would be to build a class to collect all the token
attributes in one place, somewhat like the example I posted
originally. There's many variations possible, of course.
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
More information about the Albatross-users
mailing list