Hi, I am not able to code this pattern. I read about it at many places, in doc, FAQ and at http://groups.google.co.in/group/sqlalchemy/browse_thread/thread/66d0094c671bd5bc, but still could not do it. May be my noviceness. Needing help. I tried somethings like this, but it did not help:
from sqlalchemy import * from sqlalchemy.ext.assignmapper import assign_mapper from sqlalchemy.ext.sessioncontext import SessionContext context = SessionContext(create_session) session = context.current metadata = BoundMetaData('sqlite:///satest', echo=False) # table definitions person_table = Table('person', metadata, Column('person_id', Integer, primary_key=True, autoincrement = True), Column('first_name', Unicode(30)), Column('last_name', Unicode(30))) metadata.drop_all() metadata.create_all() class Person(object): @staticmethod def Create(first_name, last_name): p = Person(first_name=first_name, last_name=last_name) p.CallAfterInitializationOrFetchingFromDatabase() return p def CallAfterInitializationOrFetchingFromDatabase(self): self.full_name = self.first_name + ' ' + self.last_name class PersonExtension(object): def create_instance(self, mapper, selectcontext, row, Person): p = Person() p.CallAfterInitializationOrFetchingFromDatabas() return p assign_mapper(context, Person, person_table, extension=PersonExtension()) p = Person.Create(first_name="Sanjay", last_name="Patel") Assert p.full_name == "Sanjay Patel" p.flush() del p session.clear() p = Person.get_by(person_id=1) assert p.full_name == "Sanjay Patel" I think using __new__ might be simpler, but can't guess how exactly to use it. thanks Sanjay --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---