[storm] Overriding database column for Storm subclass property?

Justin Warren daedalus at eigenmagic.com
Tue Jul 8 06:27:01 BST 2008


On Mon, 2008-07-07 at 15:41 +0800, James Henstridge wrote:
> On Mon, Jul 7, 2008 at 1:33 PM, Justin Warren <daedalus at eigenmagic.com> wrote:
> > Hi folks,
> >
> > I'm new to Storm, by way of Twisted, and so far I like what I see! I
> > look forward to playing more with DeferredStore sometime soon.
> >
> > My question: When defining a Storm subclass, is it possible to define
> > the database column to use for the Property, rather than having it
> > automagically use the name of the class attribute? Something like the
> > following syntax (which doesn't work):
> >
> > class Person(Storm):
> >    """
> >    My Person class, linked to an existing database schema
> >    """
> >    id = Int()
> >    name = Unicode()
> >    # I want to use Person.surname, not Person.person_lastname
> >    surname = Unicode(column='person_lastname')
> 
> The following should do what you want:
>     surname = Unicode('person_lastname')

Ah, so simple. Hooray for Storm. It works. :)

Thanks for the quick answer.

-- 
Justin Warren <daedalus at eigenmagic.com>




More information about the storm mailing list