Michael Bayer wrote:

On May 20, 2008, at 12:15 PM, Gregor Kling wrote:

its not going to work if you create the mapper() (and Table) per class
instance (i.e. within __init__),
It was a typo. It should be all SrvDomainTable.
But why shouldn't it work, I already do the test and it does.
Could you please be more specific about this ?

the mapper links itself to the class. additionally, the mapper compiles itself and places instrumentation upon the class that receives events and tracks history. Its not valid to create another primary mapper for the same class without explcitily removing the first one - it will raise an error. There's a lot of dependencies set up at the class level, and things would break very badly if they were re-created uniquely on different instances of the same class. Primary mapper construction is also a fairly expensive process in comparison with whats appropriate for object instantiation.


You mean I have to use it like this:

# srvdomain-module:
from sqlalchemy import *
from sqlalchemy.orm import mapper

from dvzrv.db import sAmetaData

class SrvDomainTable(object):
  def __init(self):
    self.domain_name = domain_name
    self.srv_id = srv_id

sAtablename = 'srv_domain'
sAsrv_domain_table = Table(sAtablename,sAmetaData,autoload=True) sAmapped_srv_domain = mapper(DVZsrvDomainTable,sAsrv_domain_table,primary_key=[sAsrv_domain_table.c.domain_name,sAsrv_domain_table.c.srv_id])


greetings
gregor

---------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to