When I try to save an item/object I get the following exception:

Traceback (most recent call last):
   File "C:\Dev\twcb\Program\dialogcontainer.py", line 418, in OnSaveButton
     mlDialogs.SaveData(self)
   File "C:\Dev\twcb\Program\multilangdialogs.py", line 34, in SaveData
     self.Getds().save(self.dbLMItem)
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.0-py2.5.egg\sqlalchemy\orm\session.py",
 
line 793, in save
     _object_mapper(object).cascade_callable('save-update', object,
   File 
"c:\python25\lib\site-packages\SQLAlchemy-0.4.0-py2.5.egg\sqlalchemy\orm\mapper.py",
 
line 1613, in object_mapper
     raise exceptions.InvalidRequestError("Class '%s' entity name '%s' 
has no mapper associated with it" % (object.__class__.__name__, 
getattr(object, '_entity_name', entity_name)))
InvalidRequestError: Class 'Mapper' entity name 'None' has no mapper 
associated with it

Looking through the doc I find that this is used when one wants an 
alternate mapper, which I don't but somehow I do something to assign 
"None" to it and I can't figure it what am I doing wrong.

I did a little test to see if I can narrow it down, but I am totally 
confused as the result is very different.

Test script:
engine = sa.create_engine(dburl, encoding='utf8', echo=False)
Session = sao.sessionmaker(autoflush=True, transactional=True)
Session.configure(bind=engine)
session = Session()
dbLMItem = getattr(db, 'Container_Lm')
print dir(dbLMItem)

Which outputs:
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', 
'__hash__', '__init__', '__module__', '__new__', '__reduce__', 
'__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 
'_sa_attribute_manager', 'c', 'centralkey', 'containerid', 'containerx', 
'created', 'fk_containerxid', 'fk_langid', 'id', 'language', 'name', 
'shortname', 'updated']

But when I debug my application I get something very different.

In my app I create the session as follows:
self.engine = db.sa.create_engine(dburl, encoding='utf8', echo=False)
self.Session = db.sao.sessionmaker(autoflush=True, transactional=True)
self.Session.configure(bind=self.engine)
self.ds = self.Session()

Then in the dialog in question I do (self.mlTable is a string 
'Container_Lm':
         self.dbLMItem = getattr(db, self.mlTable)

And if I do a dir on self.dbLMItem I get:
['_CompileOnAttr', '_Mapper__initialize_properties', '_Mapper__log', 
'_Mapper__log_debug', '_Mapper__props', '_Mapper__props_init', 
'_Mapper__should_log_debug', '_Mapper__should_log_info', 
'_Mapper__surrogate_mapper', '__class__', '__delattr__', '__dict__', 
'__doc__', '__getattribute__', '__hash__', '__init__', '__module__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', 
'__str__', '__weakref__', '_adapt_inherited_property', 
'_add_polymorphic_mapping', '_all_tables', '_assign_entity_name', 
'_check_compile', '_compile_class', '_compile_extensions', 
'_compile_inheritance', '_compile_properties', '_compile_property', 
'_compile_selectable', '_compile_tables', '_create_prop_from_column', 
'_deferred_inheritance_condition', '_eager_loaders', '_get_clause', 
'_get_equivalent_columns', '_get_poly_select_loader', 
'_getpropbycolumn', '_has_pks', '_identity_class', 
'_inheriting_mappers', '_instance', '_is_orphan', '_is_primary_mapper', 
'_post_instance', '_postfetch', '_synchronizer', 'add_properties', 
'add_property', 'allow_column_override', 'allow_null_pks', 
'always_refresh', 'base_mapper', 'batch', 'c', 'canload', 
'cascade_callable', 'cascade_iterator', 'class_', 'class_key', 
'column_prefix', 'columns', 'columntoproperty', 'common_parent', 
'compile', 'concrete', 'delete_obj', 'delete_orphans', 'dispose', 
'entity_name', 'exclude_properties', 'extension', 'get_attr_by_column', 
'get_property', 'get_select_mapper', 'get_session', 'has_eager', 
'identity_key_from_instance', 'identity_key_from_primary_key', 
'identity_key_from_row', 'include_properties', 'inherit_condition', 
'inherit_foreign_keys', 'inherits', 'instances', 'is_assigned', 'isa', 
'iterate_properties', 'iterate_to_root', 'local_table', 'logger', 
'mapped_table', 'non_primary', 'order_by', 'pks_by_table', 
'polymorphic_fetch', 'polymorphic_identity', 'polymorphic_iterator', 
'polymorphic_map', 'polymorphic_on', 'populate_instance', 'primary_key', 
'primary_key_argument', 'primary_key_from_instance', 'primary_mapper', 
'properties', 'register_dependencies', 'save_obj', 'select_table', 
'set_attr_by_column', 'single', 'tables', 'translate_row', 'version_id_col']

I would appreciate any hints on were I should look.

Werner

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

Reply via email to