sorry, i hadnt yet gotten the examples/polymorph/single.py example working, i just committed a small change to 0.2 to recognize an incoming "None" for the table argument and fixed the single.py example.

On May 23, 2006, at 5:13 AM, Vladimir Iliev wrote:

Hi,

I'm trying the single table inheritance example (see the attachment)
from the 0.2 docs, and it fails with the following traceback:

Traceback (most recent call last):
  File "single.py", line 37, in ?
    manager_mapper = mapper(Manager, inherits=employee_mapper,
polymorphic_identity='manager')
  File "f:\lib\python\pyfr\__init__.py", line 49, in mapper

  File "build\bdist.win32\egg\sqlalchemy\orm\mapper.py", line 139, in
__init__
  File "build\bdist.win32\egg\sqlalchemy\sql.py", line 39, in join
File "build\bdist.win32\egg\sqlalchemy\sql.py", line 1017, in __init__
  File "build\bdist.win32\egg\sqlalchemy\sql.py", line 1037, in
_match_primaries
AttributeError: 'NoneType' object has no attribute 'foreign_keys'

ideas ?

from sqlalchemy import *

metadata = DynamicMetaData()


class Employee(object):
    def __init__(self, name):
        self.name = name
    def __repr__(self):
        return self.__class__.__name__ + " " + self.name

class Manager(Employee):
    def __init__(self, name, manager_data):
        self.name = name
        self.manager_data = manager_data
    def __repr__(self):
return self.__class__.__name__ + " " + self.name + " " + self.manager_data

class Engineer(Employee):
    def __init__(self, name, engineer_info):
        self.name = name
        self.engineer_info = engineer_info
    def __repr__(self):
return self.__class__.__name__ + " " + self.name + " " + self.engineer_info


employees_table = Table('employees', metadata,
    Column('employee_id', Integer, primary_key=True),
    Column('name', String(50)),
    Column('manager_data', String(50)),
    Column('engineer_info', String(50)),
    Column('type', String(20))
)

employee_mapper = mapper(Employee, employees_table, polymorphic_on=employees_table.c.type) manager_mapper = mapper(Manager, inherits=employee_mapper, polymorphic_identity='manager') engineer_mapper = mapper(Engineer, inherits=employee_mapper, polymorphic_identity='engineer')


metadata.connect('sqlite://', echo=True)



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