[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Archetypes-users] Validator is not the same as itself... and it's not April 1st yet


Hi,

This error would be real funny if it had not caused me a huge amount of pain in the past couple of months. It's the result of a schema update attempt:

Traceback: 2005-02-28T15:37:48 ERROR(200) SiteError http://10.0.3.10:9080/MedicalTribune/archetype_tool/manage_updateSchema
Traceback (most recent call last):
 File "/usr/local/zope/2.7.3/lib/python/ZPublisher/Publish.py", line 107, in publish
   transactions_manager.commit()
 File "/usr/local/zope/2.7.3/lib/python/Zope/App/startup.py", line 222, in commit
   get_transaction().commit()
 File "/usr/local/zope/2.7.3/lib/python/ZODB/Transaction.py", line 241, in commit
   ncommitted += self._commit_objects(objects)
 File "/usr/local/zope/2.7.3/lib/python/ZODB/Transaction.py", line 356, in _commit_objects
   jar.commit(o, self)
 File "/usr/local/zope/2.7.3/lib/python/ZODB/Connection.py", line 452, in commit
   dump(state)
PicklingError: Can't pickle Products.MedicalTribune.archetypes.Validators.CheckListValidator: it's not the same object as Products.MedicalTribune.archetypes.Validators.CheckListValidator

Yes, haha. I asked this once before but got no answers... I guess it was because my question was not the same as my question.

Here's the relevant code:

   from Products.validation.ZService import ZService
   from Products.validation.interfaces.IValidator import IValidator

   _validators = []

   class CheckListValidator:
       """Validate that all questions in checklist were answered"""

       __implements__ = (IValidator,)

       def __init__(self, name, title='', description=''):
           self.name = name
           self.title = title or name
           self.description = description

       def __call__(self, value, *args, **kwargs):
           return ("%s: Invalid checklist" % `value`)

   _validators.append(CheckListValidator('isChecklistDone'))

   validation = ZService()
   for validator in _validators:
       validation.register(validator)


And it's used like this:

   CheckListField('checklist', validators=('isChecklistDone',),...)

Help?

TIA, Itai



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Archetypes-users mailing list
Archetypes-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/archetypes-users


This mailing list archive is a service of Copilotco.