Hi,

I noticed that __init__ method of classes derived from Entity is not
called when querying database (I inculded a sample code below). Is
there a way to call a user defined __init__ (or eventually another
method) upon instances creation triggered by a query ?

In the following code, Movie.__init__ is not called by
Movie.query.all():

from elixir import *

metadata.bind = "sqlite:///movies.sqlite"
#metadata.bind.echo = True

class Movie(Entity):
    title = Field(Unicode(30))
    year = Field(Integer)
    description = Field(Text)

    def __init__( self, *args, **kwargs ):
      print 'Movie.__init__', args, kwargs
      super( Movie, self ).__init__( *args, **kwargs )


    def __repr__(self):
        return '<Movie "%s" (%d)>' % (self.title, self.year)



print 'Create database'
setup_all()
create_all()
Movie(title=u"Blade Runner", year=1982)
session.flush()

print 'Query'
print Movie.query.all()


      Yann
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to