a class that doesn't extend your declarative base would have to be
mapped explicitly using the mapper() function, otherwise it can't be
referenced within a relation().
On Mar 31, 2009, at 8:04 AM, Alex Maslov wrote:
>
> Hello,
>
> We have been trying to mix a class inherited from declarative_base()
> ("Country") with plain Python classes mapped using orm.mapper. We're
> getting the error:
>
> UnmappedClassError: Class 'doupy.model.objects.Country' is not mapped
>
> code:
>
> Base = declarative_base()
> class Country(object):
> __tablename__ = 'countries'
> ...
>
> Base.metadata.bind = engine
>
> We also tried to create Base using
> Base = declarative_base(bind=engine)
> and
> Base = declarative_base(metadata=meta)
>
> with the same error.
>
> Full traceback below:
> File '/Users/amaslov/Projects/dou-pylons/doupy/doupy/model/
> __init__.py', line 73 in <lambda>
> return property(fget=lambda self: self.session.query(cls))
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/session.py', line
> 898 in query
> return self._query_cls(entities, self, **kwargs)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/query.py', line 91
> in __init__
> self._set_entities(entities)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/query.py', line 100
> in _set_entities
> self.__setup_aliasizers(self._entities)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/query.py', line 114
> in __setup_aliasizers
> mapper, selectable, is_aliased_class = _entity_info(entity)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/util.py', line 485
> in _entity_info
> mapper = class_mapper(entity, compile)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/util.py', line 560
> in class_mapper
> mapper = mapper.compile()
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/mapper.py', line
> 662 in compile
> mapper._post_configure_properties()
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/mapper.py', line
> 691 in _post_configure_properties
> prop.init()
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/interfaces.py',
> line 408 in init
> self.do_init()
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/properties.py',
> line 707 in do_init
> self._get_target()
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/properties.py',
> line 719 in _get_target
> self.mapper = mapper.class_mapper(self.argument, compile=False)
> File '/Users/amaslov/Projects/dou-pylons/py/lib/python2.5/site-
> packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/orm/util.py', line 557
> in class_mapper
> raise exc.UnmappedClassError(class_)
> UnmappedClassError: Class 'doupy.model.objects.Country' is not mapped
>
> Any help is very much appreciated!
>
> Regards,
> Alex
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---