My goal is to have a one-to-many relation defined using the same name 
as the foreign key column underneath.  So that, if my "Detection" 
table has a foreignkey column named "sensor," the following mappers 
should work, I think:

mapper(Sensor, sensor)
detectionmapper = mapper(Detection, detection, 
allow_column_override=True, properties={
     'sensor': relation(Sensor),
})

I'm getting the following exception, however, when I actually create 
a Detection with a Sensor and try to flush the session:

Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\scoping.py",
 
line 98, in do
     return getattr(self.registry(), name)(*args, **kwargs)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\session.py",
 
line 757, in flush
     self.uow.flush(self, objects)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 233, in flush
     flush_context.execute()
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 445, in execute
     UOWExecutor().execute(self, tasks)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 930, in execute
     self.execute_save_steps(trans, task)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 948, in execute_save_steps
     self.execute_dependencies(trans, task, False)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 959, in execute_dependencies
     self.execute_dependency(trans, dep, False)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 942, in execute_dependency
     dep.execute(trans, isdelete)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py",
 
line 895, in execute
     self.processor.process_dependencies(self.targettask, [elem.state 
for elem in self.targettask.polymorphic_tosave_elements if elem
.state is not None], trans, delete=False)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\dependency.py",
 
line 332, in process_dependencies
     self._synchronize(state, child, None, False, uowcommit)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\dependency.py",
 
line 374, in _synchronize
     sync.populate(child, self.mapper, state, self.parent, 
self.prop.synchronize_pairs)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\sync.py",
 
line 27, in populate
     self._raise_col_to_prop(True, source_mapper, l, dest_mapper, r)
NameError: global name 'self' is not defined


I am still using SQLAlchemy 0.4.5.

Thanks for any help!
Chris 
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to