Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
On Thu, Sep 22, 2005 at 12:11:26PM +0200, Tomas wrote:
> patch for object accessing to attributes via indexing
> obj['name'] returns obj.name
> obj['type.name'] returns obj.type.name
I am not sure this is in accord with SQLObject that is designed for
I think you'd beter make this as a wrapper object instead.
BTW, some people ask if they can create a dictionary out of SQLObjects.
The wrapper object is, probably, an answer.
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.
From: Ian Bicking <ianb@co...> - 2005-09-22 15:54:22
Oleg Broytmann wrote:
> On Thu, Sep 22, 2005 at 12:11:26PM +0200, Tomas wrote:
>>patch for object accessing to attributes via indexing
>> obj['name'] returns obj.name
>> obj['type.name'] returns obj.type.name
> I am not sure this is in accord with SQLObject that is designed for
> attribute access.
> I think you'd beter make this as a wrapper object instead.
I'd be fine with a method/property on sqlmeta that returns a dictionary
of the object's column values. Maybe even two methods, with one that
returns a "live" dictionary (where setting keys changes the SQLObject
instance). But SQLObject instances definitely won't grow a dictionary
interface directly. Also, __getitem__ without a full compliment of
dictionary methods is just likely to annoy people -- at least, I know I
am annoyed by almost-but-not-quite dictionaries. UserDict.DictMixin
makes full dictionaries easy enough to write.
However, the second form (obj['type.name'] is obj.type.name) doesn't
make me comfortable; much too magic.
Ian Bicking / ianb@... / http://blog.ianbicking.org