currently there is no "wrapping of properties" going on, SA sets its own property-like object which replaces one that was already there.

so you just need to operate upon a different property name, usually "_attr", and tell your mapper about the alternate column mapping like this:

m = Mapper(Entity, entities, properties = {
        '_attr': entities.c.attr
})

I have just added a similar example to the "basic datamapping" synopsis in the docs since this question is the most common.

On Feb 20, 2006, at 11:08 AM, dmiller wrote:

When I first read the SA documentation I got the impression I could do this:


class Entity(object):
    def _get_attr(self):
        # get logic
    def _set_attr(self):
        # set logic
    attr = property(_get_attr, _set_attr)

entities = Table("entities",
    Column("id", ...),
    Column("attr", ...)
)

m = Mapper(Entity, entities)


I got the impression that SQLAlchemy would transparently wrap access to Entity.attr to track history, etc. However, I was rudely awakened when I realized that such code was not working...my "Entity.attr" property is simply overwritten by AttributeManager.register_attribute(...), which puts a SmartProperty there instead.

Am I overlooking something? Is there a way to do this? Could AttributManager and/or SmartProperty be improved to support properties as well as normal attributes?

~ Daniel


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel? cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to