I'm using sqlalchemy for the first time and want to follow standard or "best" practices. I have rather fundamental scenario in a turbogears project:
- Form post back to exposed method "foo" - using passed params, "foo" creates an object "thing" - "thing" is saved - redirect is raised to "/url/to/thing/%s" % thing.id My question: what's considered the standard way of doing this? To eliminate some ambiguity, here's some pseudo-source code: thing_table = Table('thing', metadata, Column('id', Integer,primary_key=True), Column('name', String(16),nullable=False), Column('text', String(255),nullable=False) ) class Thing(object): def __repr__(self): return "Thing id:%d name:%s text: %s" % \ (self.id, self.name, self.text) assign_mapper(session.context, Thing, thing_table) class Root(controllers.Controller) ...... things = Things() class Things(controllers.Controller) .... @expose(template='.templates.newthing') def newthing(self, tg_errors=None): ........ @expose() @validate(form=new_thing_form) @error_handler(new) def foo(self, name, text): thing = Thing(name=name,text=text) thing.save() session.flush() raise redirect('/things/%s' % thing.id) @expose(template='my_project.templates.index') def index(self, thing_id, tg_errors=None): thing=None if not thing_id: thing = Thing.get(thing_id) return dict(thing=thing) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---