yeah, this is something that should probably be added to SA, which is that your own properties dont get blown away by those set up by SA.

For now, do it like this:

http://www.sqlalchemy.org/docs_02/ adv_datamapping.myt#advdatamapping_properties_overriding


On May 21, 2006, at 4:25 AM, Koen Bok wrote:

I'd like to do something really simple. I have an order with some products related to it. When I set the quantity of a product to 0, I'd like it to destroy itself.

The property quantity is bound to the quantity table column by a mapper.

But when I do product.quantity = 123, _set_quantity does not get called. What am I doing wrong? Using 0.2 latest SVN.

class Product(object):
        
        def _set_quantity(self, quantity):
                print "I GOT CALLED!"
                self.quantity = quantity

        def _get_quantity(self, quantity):
                return self.quantity
        
        quantity = property(_get_quantity, _set_quantity)



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to