Nothing gets placed in the Session initially without at least one call to add(). When an object is added which contains references to other objects, or other objects are associated with an object already present in the session, cascade rules take effect which result in those related objects also being added to the session implicitly, assuming default cascade rules have not been overridden. Information on cascade is at http://www.sqlalchemy.org/docs/orm/session.html#cascades .
On Dec 6, 2010, at 5:29 AM, werner wrote: > Hi, > > I sometimes see this type of error: > > Traceback (most recent call last): > > File "dialognewwine.pyo", line 750, in OnSaveButton > File "dialognewwine.pyo", line 768, in SaveData > File "sqlalchemy\orm\session.pyo", line 924, in refresh > File "sqlalchemy\orm\session.pyo", line 1234, in _validate_persistent > InvalidRequestError: Instance '<Purchase at 0xdac9df0>' is not persistent > within this Session > > Inspecting my code I see that I forgot to call session.add, however the same > code works most of the time without complaining. > > Are there situations where session.add doesn't need to be called? > > Werner > > P.S. Using SA 0.6.5 > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" 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/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" 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/sqlalchemy?hl=en.
