Hi there,

I've got a crappy legacy database that has a _rowid and an id column
(they have totally separate meanings. In my orm, I want 'id' to map to
_rowid and 'document_id' to map to id in the table. Easy enough -- I
set it up like this:

mapper(Document, documents, properties={
    'document_id': documents.c.id,   # document_id ORM property
references id column
    'id': documents.c._rowid,             # id ORM property references
_rowid column
...

It works fine. But now I want to add a descriptor to my ORM class to
do some extra processing whenever document_id is referenced:

class Document(object):
    @property
    def document_id(self):
        return self._document_id

    @document.setter
    def document_id(self, value):
        # <do some processing...>
        self._document_id = value

In the past, I have successfully mapped these properties using
synonym, but this time I'm confused because I'm not sure how to define
the synonym to a different column name. How do I change my
'document_id': declaration in the mapper call to set up the above
descriptor when accessing the id column on the table?

Thanks,
Dusty

--~--~---------~--~----~------------~-------~--~----~
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