Hello everyone!

I'm trying to migrate from SqlAlchemy 0.6.8 to 0.7.4.

I have a class that is the base for all the bases in my system. In
that class is where I define the id (numeric primary key) for the rest
of my classes. That class is not mapped to any table.

I want to have getter/setter for said "id", making it a
hybrid_property, something like:

class BaseClass(object):
        _id = Column("id", Integer, primary_key=True, key="id")

        @hybrid_property
        def id(self):
                return self._id
        @id.setter
        def setId(self, id):
                try:
                        self._id = int(id)
                except TypeError:
                        self._id = None

but if then i try to use the id in filters (such as
Product.manufacturer.any(id=parameterId), where Product is a "really"
mapped class, with a relationship towards Manufacturer, another
"really" mapped class, ) I get a key error "id", so it looks like the
"id" is not property set.

In 0.6.8, what I did was

class BaseClass(object):
         _id =  Column("id", Integer, primary_key=True, key="id")

        @declared_attr
        def id(cls):
                return synonym('_id', descriptor=property(cls.getId, cls.setId))


I've tried as many dirty tricks as I could come up with, and I didn't
get any success... Any ideas will be welcome!

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to