This creates an attribute named k; it does not create an attribute
whose name is the *value* of k. For that you need setattr:
setattr(self, k, v)
There is a shortcut that replaces the entire loop:
self.__dict__.update(atts)
Thanks Kent, that explains a lot about how things work.
return an empty string for any attribute. I'm making a very simple
CMS with Cherrypy/Sqlalchemy/Cheetah,
Those are the components of TurboGears.
You might save a lot of bother by using TG instead of trying to
write all the glue code yourself. Form handling for one would
come for free, as would logins, help pages etc etc.
OTOH maybe you are doing this as a learning exercise in
which case have at it! :-)
I am doing this as a learning exercise, though I hadn't realized those
are precisely TG's components. I'm actually coming at this from
Django, and wanted to approach things at a lower level (every time a
friend asks me to make a website for them I use it as an excuse to
learn some new framework components). I wasn't really missing Django
until I got to the 'CMS backend' stage of things – forms for models,
validation, etc. I'll stick through the learning exercise, but it will
be *very* nice to return to a full framework package...
Eric
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor