Modify ↓
Ticket #29 (closed defect: fixed)
Validator subclasses can't access superclass messages method
| Reported by: | jcmcken@… | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.5 |
| Keywords: | Cc: |
Description (last modified by fs) (diff)
Your superclass magic may be too magical for me. Or maybe I'm not doin' it right
from pycerberus.api import Validator
>>> class FooValidator(Validator):
... def messages(self):
... super_msg = Validator.messages(self).copy()
... return super_msg.update({'foo':u'bar'})
...
>>> FooValidator()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/pycerberus-0.4.2-py2.6.egg/pycerberus/api.py", line 165, in __init__
self._implementations, self._implementation_by_class = self._freeze_implementations_for_class()
File "/usr/lib/python2.6/site-packages/pycerberus-0.4.2-py2.6.egg/pycerberus/api.py", line 187, in _freeze_implementations_for_class
for key in cls.keys(self):
TypeError: 'NoneType' object is not iterable
Attachments
Change History
comment:3 Changed 3 months ago by fs
Just return the new/updated keys, that should work. The "magic" will collect all the other messages from your super classes:
class FooValidator(Validator): def messages(self): return {'foo': u'bar'}
I tried to express that in the docs:
Return all messages which are defined by this validator as a key/message dictionary.
Please point me to places where I should improve the documentation.
Did that help?
Note: See
TracTickets for help on using
tickets.
