[Zope3-Users] Re: zope.schema Question

Tim Cook timothywayne.cook at gmail.com
Mon Jul 7 06:06:48 EDT 2008



On Mon, 2008-07-07 at 09:56 +0200, Philipp von Weitershausen wrote:

> > Now I want to allow description to be any descendant of ItemStructure.
> > So I had hoped that:
> >
> >    description=Object(
> >        schema=IItemStructure,
> >        title=_(u"Description"),
> >        description=_(u"Description of the activity."),
> >        required=True,
> >    )
> >
> > would provide that functionality.  It still throws a WrongTypeError.
> 
> The declaration looks ok. What throws a WrongTypeError where?
> 
> > I feel like the answer lies somewhere in the zope.interface.implement*
> > functions but I lack the Zen to get the right combination.
> 
> It's hard to tell w/o knowing what actually throws the exception.

I think I was misreading the traceback.  In stepping through the debugger I was able to determine 
that the <type 'unicode'> in the error is referring to description entries several layers up the inheritance tree.
I had copy/pasted a lot of this from the specifications document and
there are the strange backwards single and double quote characters in
the text. The documents were created with Framemaker and then saved to
PDF. 

So once I remove all those characters I can get back to the task at
hand.  

Am I correct in thinking that the above definition of
Activity.description will constrain the possible types to the classes
implementing IItemStructure or a subclass of it?


BTW: The traceback is below.  I don't think it would have been possible
to find this without stepping through the debugger and watching the
stack data.

Cheers,
Tim

  File
"/home/tim/projects/ref_impl_python/TRUNK/oship/src/oship/atbldr/bldinstruction.py", line 28, in bldInstruction
    actObj=bldActivity(activities,errlog,ontology)
  File
"/home/tim/projects/ref_impl_python/TRUNK/oship/src/oship/atbldr/bldactivity.py", line 38, in bldActivity
    actObj=Activity(descr,timing,actionArchetypeId,nodeid)
  File
"/home/tim/projects/ref_impl_python/TRUNK/oship/src/oship/openehr/rm/ehr/composition/content/entry/activity.py", line 40, in __init__
    self.description=descr
  File
"/home/tim/buildout-eggs/zope.schema-3.4.0-py2.4.egg/zope/schema/fieldproperty.py", line 52, in __set__
    field.validate(value)
  File
"/home/tim/buildout-eggs/zope.schema-3.4.0-py2.4.egg/zope/schema/_bootstrapfields.py", line 138, in validate
    self._validate(value)
  File
"/home/tim/buildout-eggs/zope.schema-3.4.0-py2.4.egg/zope/schema/_bootstrapfields.py", line 263, in _validate
    super(MinMaxLen, self)._validate(value)
  File
"/home/tim/buildout-eggs/zope.schema-3.4.0-py2.4.egg/zope/schema/_bootstrapfields.py", line 165, in _validate
    raise WrongType(value, self._type)
zope.schema._bootstrapinterfaces.WrongType:
(<openehr.rm.datastructures.itemstructure.itemtree.ItemTree object at
0x7f4b3be6f610>, <type 'unicode'>)
(


-- 
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook 
Skype ID == timothy.cook 
**************************************************************
*You may get my Public GPG key from  popular keyservers or   *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20080707/8f8ce51a/attachment.bin


More information about the Zope3-users mailing list