[storm] I get a multiple matches exception, but it shows me the same match twice

Gabriel Rossetti gabriel.rossetti at arimaz.com
Fri Jul 25 13:58:29 BST 2008


Gabriel Rossetti wrote:
> Hello,
>
> I get an exception that says it found multiple matches for a class 
> member, but it shows me the same match twice, is there a bug?
>
> I tried this (simplified):
>
> class User(Storm):
>     """
>     Maps the C{user} table in the database
>     """
>    
>     __storm_table__ = "user"
>    
>     id = Int(primary=True, name="user_id")
>     firstName = Unicode(name="first_name")
>     lastName = Unicode(name="last_name")
>     languageId = Int(name="language_id")
>     language = Reference(languageId, u"Language.id")
>    
>     def __init__(self, firstName, lastName, lang):
>         self.firstName = firstName
>         self.lastName = lastName
>         self.language = lang
>
> class Language(Storm):
>     __storm_table__ = "language"
>    
>     id = Int(primary=True, name="language_id")
>     name = Unicode()
>    
>     def __init__(self, name):
>         self.name = name
>
> def populateDb(store)
>     lang1 = Language(u"ENGLISH")
>     store.add(lang1)
>     lang2 = Language(u"FRENCH")
>     store.add(lang2)
>    
>     user1 = User(u"Gabriel", u"Rossetti", lang1)
>     store.add(user1)
>
>
> and I get this :
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "services/common/orm.py", line 704, in populateDb
>     user1 = User(u"Gabriel", u"Rossetti", lang1)
>   File "services/common/orm.py", line 137, in __init__
>     self.language = lang
>   File "/usr/lib/python2.5/site-packages/storm/references.py", line 133, 
> in __set__
>     self._build_relation(local.__class__)
>   File "/usr/lib/python2.5/site-packages/storm/references.py", line 155, 
> in _build_relation
>     self._remote_key = resolver.resolve(self._remote_key)
>   File "/usr/lib/python2.5/site-packages/storm/references.py", line 773, 
> in resolve
>     return (self.resolve_one(properties),)
>   File "/usr/lib/python2.5/site-packages/storm/references.py", line 780, 
> in resolve_one
>     return self._resolve_string(property)
>   File "/usr/lib/python2.5/site-packages/storm/references.py", line 796, 
> in _resolve_string
>     return registry.get(property_path, self._namespace)
>   File "/usr/lib/python2.5/site-packages/storm/properties.py", line 284, 
> in get
>     (name, ", ".join(paths)))
> storm.exceptions.PropertyPathError: Path 'Language.id' matches multiple 
> properties: services.common.orm.Language.id, services.common.orm.Language.id
>
> Does anyone have any ideas? Also, I tried to use the debugging method 
> like shown in the tutorial, but storm.tracer doesn't exist anymore, was 
> this replaced by something else? (I know it wouldn't help me find the 
> error in this case)
>
> Thanks,
> Gabriel
>
>   
I found the error if anyone ever has this too : in my reference 
declarations, I used a unicode string... The error isn't very indicative 
of the problem, but if you replace :

language = Reference(languageId, u"Language.id")

with :

language = Reference(languageId, "Language.id")

it works.

And for the debugging, apparently storm.tracer doesn't exist yet, other 
than in trunk, so I think storm.database.DEBUG = True is the way to go 
for now.

Gabriel





More information about the storm mailing list