Morning Guys,
I'm looking to build a uniform method for getting/creating instance of my objects from the database. At the moment I've been using query(SomeObject).get(object_id) to return the objects from the DB, however, it would be really great if there were a method which always returned a result, so, if I pass in an id of '354' to the get() method and no record with that ID exists in the database, then it just returns a new empty instance of the SomeObject class with the id set to 354. Does such a method exist on the ORM? If not then how would you go about doing so? I came about to this way of thinking when I've been having problems instantiating my own instances of classes which are decoratively mapped to the database. So if I try to create a new instance of a class like so: Import SomeObject New_insatnce = SomeObject.SomeObject(354) Then I get an error thrown about how I'm not able to assign a str value to attributes which are expecting a mapped instance, presumably a relationship. Am I thinking straight here? Or does SQLAlchemy have a separate method for creating new clean instances of its objects? Cheers, Heston --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---