[EMAIL PROTECTED] wrote:

Steve Bergman wrote:
Yes.  I've been looking forward to that feature's debut in TG.  Can I
also pass a dictionary to SQLObject to set the attributes of an existing
or new object to the dictionaries values?  It seems like I saw somewhere
that I can already do that?
Using the .set(**dict) or something like that should do the trick

Thanks.  That works just fine for updating a record.

I've converted everything in my app from using the TG validation mechanism, to your method of passing all function arguments as **kw and using schemas. Also, to use the .set method for updates. I must say, you were right. I like this style. It feels more Pythonic. ( I can almost hear it hissing. ;-P )

Hopefully with the next release I'll be able to retrieve an object's attributes into a dictionary in just a single statement as Leandro was kind enough to point out.

So, is there a way to create a *new* object and feed it a dictionary in a concise way? I can't just create an empty object and then use .set because, of course, it complains about missing attributes when I create the object.

Also, the way I am doing things is to pass all function/method args in **kw and setting allow_extra_fields and filter_extra_fields to True in the schema. Any function arguments that don't go into the database just get a dummy line in the schema so they don't get stripped prematurely. Then, right before I actually add or update, I pop the extra values off to avoid the object complaining about unexpected attributes when I update.

Does that sound like the most efficient way to do it?

Thanks,
Steve

Reply via email to