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

13 views
Skip to first unread message

Luís Martinho

unread,
May 19, 2011, 1:29:46 PM5/19/11
to colony...@googlegroups.com
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\\web_mvc_utils.py\", 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\/url_minifier_controllers.py\", 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\/url_minifier_controllers.py\", 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\\entity_manager_system.py\", 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\\entity_manager_sqlite_engine_plugin.py\", 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\\entity_manager_sqlite_engine_system.py\", 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

unread,
May 19, 2011, 1:34:53 PM5/19/11
to colony...@googlegroups.com
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 <lmar...@hive.pt>

Luís Martinho

unread,
May 19, 2011, 1:39:21 PM5/19/11
to colony...@googlegroups.com
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
lmar...@hive.pt
+351 93 405 72 40

url_minifier_controllers.py
url_minifier_entity_models.py

Tiago Silva

unread,
May 19, 2011, 1:49:09 PM5/19/11
to colony...@googlegroups.com
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 <lmar...@hive.pt>

Luís Martinho

unread,
May 19, 2011, 2:11:32 PM5/19/11
to colony...@googlegroups.com
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:

|d3eb2c03475629d4ffdbdb790e22abb1|1|1|http://hive.pt
|d3eb2c03475629d4ffdbdb790e22abb1|2|1|http://hive.pt

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

Url|d3eb2c03475629d4ffdbdb790e22abb1|1|1|http://hive.pt
Url|d3eb2c03475629d4ffdbdb790e22abb1|2|1|http://hive.pt

Which looks much nicer.

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

Thanks for this!

João Magalhães

unread,
May 19, 2011, 6:19:37 PM5/19/11
to colony...@googlegroups.com
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
Forward
0 new messages