Jo wrote:
[SNIP]
> 
> -------------------------------- and---------------------------------
> 
> In [13]: aa=Anagrafica.get(111)
> 
> In [14]: aa.delete()
> 
> In [15]: aa.flush()
> 
> ---------------------------------------------------------------------
> 
> but in version 0.6 I can't find flush(), save(), delete(). 
> Where are them?
> 
> thank you
> 
> j
> 

These methods were added to your objects by the old assign_mapper
extension. This extension no longer exists, and the methods on the
Session should be used instead. For example, instead of aa.delete(), you
would say session.delete(aa).

If you want to preserve your old API, you could create a base class for
your mapped objects that implements each of the old methods. A delete
method might look like this (untested):

class Base(object):
    def _get_session(self):
        return sqlalchemy.orm.object_session(self)

    def delete(self):
        session = self._get_session()
        session.delete(self)


The flush method would correspond to session.flush([self]), but you
should read the deprecation warning about passing a list of objects at
http://www.sqlalchemy.org/docs/reference/orm/sessions.html#sqlalchemy.or
m.session.Session.flush.

Assuming that the save() method adds the object to the current
contextual (scoped) session, it would be as simple as:

    def save(self):
        session = Session()
        session.add(self)

However, I personally wouldn't add that one, as it ties your class to
the scoped session mechanism which may not always be what you want.

Hope that helps,

Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to