Hi,
I have a model that has many relations and when creating a new object I
also have to create its relations objects.
Right now I have a huge controller create action (100 lines) which does
this, but I would like to decompose it into smaller parts. I thought
about writing methods for the model class, e.g.
class SomeRelatedModel(Base):
# something
class MainModel(Base):
# something
some_related_objects = relationship(SomeRelatedModel)
def add_some_related_object(self, param1, param2):
# here I need to check sth in even other model
Session.query(SomeOtherModel).filter...
# some more stuff and checks
object = SomeRelatedModel()
object.param1 = param1
object.param2 = param2
self.some_related_objects.append(object)
Is it considered bad practice to make DB queries in model's methods? Or
is this the way to go? How do you decompose such complex actions?
Regards,
--
Juliusz Gonera
http://juliuszgonera.com/
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en.