Skip to Navigation | Skip to Content

Ref_impl_Python mailing list archives

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

Re: [Oship] TASK - Last and most difficult


I'm going to take care of this one myself over this next week.

--Tim


On Thu, 2009-01-29 at 17:07 -0200, Tim Cook wrote:
> In getting rid of the never ending hell of import issues with regards 
> to
> using the Object field; i.e.
> 
> 
> ***************************************************
> From the old History interface:
>     duration=Object(
>         schema=IDvDuration,
>         title=_(u"duration"),
>         description=_(u"""Duration of the entire History; either
> corresponds to the duration of all 
>                     the events, and/or the duration represented by the
> summary, if it exists."""),
>         required=False
>     )
>     
>     summary=Object(
>         schema=IItemStructure,
>         title=_(u"summary"),
>         description=_(u"""Optional summary data expressing e.g. text 
> or
> image which summarises 
>                          entire History."""),
>         required=False
>     )
>  
> **********************************************************************
> The same two attributes now look like this in the new history 
> interface:
> 
>     duration=Field(
>         #schema=IDvDuration,
>         title=_(u"duration"),
>         description=_(u"""Duration of the entire History; either
> corresponds to the duration of all 
>                     the events, and/or the duration represented by the
> summary, if it exists."""),
>         required=False
>     )
>     
>     summary=Field(
>         #schema=IItemStructure,
>         title=_(u"summary"),
>         description=_(u"""Optional summary data expressing e.g. text 
> or
> image which summarises 
>                          entire History."""),
>         required=False
>     )
>  ***************************************************************
> 
> 
> At first glance there may not appear to be much difference.  But 
> notice
> that the call to the schema is commented out in the new one and that
> Object( is now Field(
> 
> What this means is that the History schema will not verify that those
> attributes actually inherit those schemas.  Which it never really 
> seemed
> to work anyway and there was no trail down the Object() field to the
> leaf as I was first led to believe.  
> 
> 
> So now instead, we let the schema allow anything it wants as an
> attribute value.  But in the implementation we can test that actual
> object instance to see if it does or does not inherit that schema.
> That's why I just commented them out for now so they can be used as
> references.  
> 
> (we have imported: from zope.interface.verify import verifyObject)
> 
> In the initialization of the class it will look like this for the two
> attributes we are showing:
>     
> class History(DataStructure):
>     implements(IHistory)  # this still covers the normal zope.schema
> classes
>     
>     def __init__(self,origin,events,period,duration,summary):
>        
>          if not verifyObject(IDvDuration,duration):
>             raise TypeError, u"duration must implement IDvDuration"
>               
>          if not verifyObject(IItemStructure,summary):
>             raise TypeError, u"summary must implement IItemStructure"
> 
> 
>         self.origin=origin
>         self.events=events
>         self.period=period
>         self.duration=duration
>         self.summary=summary
> 
> If no errors are raised then everything proceeds.  This way we are
> testing the actual instances passed to the application from anywhere 
> not
> just the ones being created through forms.
> 
> So, if you want to tackle just a class or two that is great or a whole
> file.  Please let me know.
> 
>  adl.py
>  archetype.py
>  common.py
>  datastructure.py
>  datatypes.py
>  demographic.py
>  ehr.py
>  extract.py
>  integration.py
>  openehrprofile.py
>  sm.py
>  support.py
> 
> 
> Regards,
> --Tim
> 
> 
> 
> 
> 
> 
> 
-- 
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*
**************************************************************

Attachment: signature.asc
Description: This is a digitally signed message part