Awesome, y'all are so smart.
My code now looks cleaner and probably a bit faster.
Thanks!
On Sep 20, 5:21 pm, Jason Chu <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 20, 2007 at 08:32:01PM -0000, shadowfox wrote:
>
> > Neat, but it only replaces the TreeBark.__dict__
>
> > Do you have another short hand to replace the ugly
> > self.__dict__.get('_SO_val_%s' % a) ?
>
> > To be less cryptic, the idea is to get the actual value of the said
> > column in a class instance.
>
> > On Sep 20, 12:54 pm, Jason Chu <[EMAIL PROTECTED]> wrote:
> > > > class TreeBark(SQLObject):
> > > > property1 = StringCol(length=150, varchar=True,title="Main Picture
> > > > URL")
> > > > property2 = StringCol(length=100,varchar=True,title="Title or
> > > > Short Description",alternateID=True,notNone=True)
>
> > > > def gimmeDict(self):
> > > > d = TreeBark.__dict__
> > > > props = dict()
> > > > for a in d:
> > > > if type(d[a]) == property:
> > > > props[a] = self.__dict__.get('_SO_val_%s' % a)
>
> > > > props['id'] = self.id
> > > > return props
>
> > > I usually find it much better to read TreeBark.sqlmeta.columnList than
> > > __dict__. You can even figure out what type of column it is from there.
>
> > > Jason
>
> props = dict()
> for column in self.sqlmeta.columnList:
> props[column] = getattr(self, column)
>
> # I'm not sure if 'id' is in that columnList.
>
> Jason
>
> application_pgp-signature_part
> 1KDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---