KeyError while accessing entity_sub_classes_map[entity_class_name] in my web.mvc_service plugin

Skip to first unread message

Luís Martinho

May 19, 2011, 1:29:46 PM5/19/11
This is kind of test drill to see if and how the community support engine is running.

I just downloaded the latest colony build along with the base plugins. I deployed. I installed the scaffolding stuff and generated an mvc scaffold for my url minifier application.
I started search-replacing RootEntity with Url. I have an UrlController, and configured the corresponding patterns.

{"exception":{"message":null,"traceback":[" File \"C:\\Users\\lmartinho\\Downloads\\colony\\plugins\\web_mvc_utils\\mvc_utils\\\", line 309, in decorator_interceptor\n return_value = function(*args, **kwargs)\n"," File \"C:\\Users\\lmartinho\\Downloads\\colony\\var\\development\\pt.hive.colony.plugins.url_minifier\\url_minifier\\minifier\/\", line 94, in handle_list_serialized\n url_entities = self._get_url_entities(rest_request, filter)\n"," File \"C:\\Users\\lmartinho\\Downloads\\colony\\var\\development\\pt.hive.colony.plugins.url_minifier\\url_minifier\\minifier\/\", line 297, in _get_url_entities\n url_entities = url_minifier_entity_models.entity_manager._find_all_options(url_minifier_entity_models.Url, filter)\n"," File \"C:\\Users\\lmartinho\\Downloads\\colony\\plugins\\data\\entity_manager\\\", line 755, in _find_all_options\n return self.entity_manager_engine_plugin.find_all_entities_options(connection, entity_class, None, None, options)\n"," File \"C:\\Users\\lmartinho\\Downloads\\colony\\plugins\\\", line 183, in find_all_entities_options\n return self.entity_manager_sqlite_engine.find_all_entities_options(connection, entity_class, value, search_field_name, options = options)\n"," File \"C:\\Users\\lmartinho\\Downloads\\colony\\plugins\\data\\entity_manager_sqlite_engine\\\", line 2579, in find_all_entities_options\n entity_class = entity_sub_classes_map[entity_class_name]\n"],"exception_name":"KeyError"}}

I've tried to review my models module and my controllers module, but can't seem to spot the problem.
Can anyone help me?

Tiago Silva

May 19, 2011, 1:34:53 PM5/19/11
can you send me the models file to check it out? I suspect there's an error in your model definition...

2011/5/19 Luís Martinho <>

Luís Martinho

May 19, 2011, 1:39:21 PM5/19/11
thanks, Tiago. 
please take into account that I can successfully create entities, I get them back serialized in JSON and I've checked the SQLite database in the meta folder and the record is there.
that's why I'm sending the controllers file as well.
Luís Martinho
+351 93 405 72 40

Tiago Silva

May 19, 2011, 1:49:09 PM5/19/11
very weird... i'm not seeing anything strange in your code... can you debug, step into, and give me the contents of "entity_sub_classes_map" and "entity_class_name" just before the error occurs?

2011/5/19 Luís Martinho <>

Luís Martinho

May 19, 2011, 2:11:32 PM5/19/11
I'm using Eclipse with PyDev, as you know. I created a new project and pointed the contents at the place where I installed colony.
I put a break point in my _find_all_options call to the entity manager.
I stepped into until the point where it breaks and I inspected this:

entity_sub_classes_map: dict: {'Url': <class 'url_minifier_entity_models.Url'>, 'RootEntity': <class 'url_minifier_entity_models.RootEntity'>}
entity_class_name:  NoneType: None

My query_string_value is str: select "Url" as class_data_type, hash, object_id, user_session_id, value from Url union all select "RootEntity" as class_data_type, "" as hash, object_id, "" as user_session_id, "" as value from RootEntity limit 0, -1
When I throw the query at the sqlite database I get this:


Which means class_data_type is coming out empty.
If I replace the double quotes with single quotes I get this:


Which looks much nicer.

I'm using Python 2.6.6 and
>>> sqlite3.sqlite_version
>>> sqlite3.version

Thanks for this!

João Magalhães

May 19, 2011, 6:19:37 PM5/19/11
There was a bug in the creation of SQL queries in the SQLite adapter plugin.
The problem should be fixed in commit 14286.
Reply all
Reply to author
0 new messages