Re: [Zope3-Users] Set List constraints

2008-07-11 Thread Tim Cook

I appreciate the list members time and patience.  I used Zope heavily
2000-2003 but after not writing any code for almost five years this is
like starting over. :-)

On Fri, 2008-07-11 at 06:48 +0200, Markus Kemmerling wrote:
 You want to restrict the elements of a list to instances that provide  
 a given interface IMyClass, right? That's exactly what a field's  
 value_type attribute is for: 

Thanks.  I missed that in the docs about collections.

 
 is meant to be used in class definitions to declare that a class  
 itself -- not is instances -- provides a given interface.
 

I use that and I guess that's why I thought it might do double duty.

 I am not sure if I get this. If you set an instance of a mutable type  
 like a list as an attribute of some other instance described by a  
 schema, it will be validated, but still remain mutable (finally your  
 other object only holds a reference to your mutable). It doesn't  
 matter if it is persistent or not, or if it was copied before. But I  
 might misunderstand your intention here.

As usual a bit of context will help if you'll bear with me.

I am implementing a set of healthcare application specifications
designed (over almost 2 decades) to maintain semantic context of
information across applications and to be implementable in any OO
language. There are implementations in Eiffel,Java and .Net. 
 http://www.openehr.org This will reduce the number healthcare data
silos since any application in any language can exchange information.

The reference model describes broad concepts such as
observation,instruction,action,etc along with the required data types
and data structures to support them.

The 'instances', referred to above, are created as constraints on the
reference model in order to define a maximal dataset for ONE clinical
concept, i.e. blood pressure. These definitions are parsed from a
special purpose language (see attachment) designed to describe the
entire semantics of that concept.  Since (with my code) parsing one of
these and creating the in-memory object takes  about .1 - .2 secs. and
since an application may use as many as 20 on a screen it is out of the
question to do it on-the-fly.  

My solution then is to pre-store these in a repository in the ZODB as a
kind of template.  An application can then reuse these by making a
copy. 

My priorities are:

1. To demonstrate implement-ability in Python.   

2. Have a platform that can be used to demonstrate and teach the
reference model and archetypes in use to a broad audience; physicians,
health care researchers, computer science and medical students, etc.

3. Build an interested open source community where 'real' developers can
fine tune my code and create wonderful interoperable healthcare
applications using the reference model in their chosen language.


So, yes I am recruiting developers to what I believe is a good cause
project. In the interim I will keep plugging away at.  :-)


Thanks,
Tim





-- 
**
Join the OSHIP project.  It is the standards based, open source
healthcare application platform in Python.
Home page: https://launchpad.net/oship/ 
Wiki: http://www.openehr.org/wiki/display/dev/Python+developer%27s+page 
**


openEHR-EHR-OBSERVATION.blood_pressure.v1.adl
Description: application/extension-adl


signature.asc
Description: This is a digitally signed message part
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Set List constraints

2008-07-10 Thread Tim Cook
When constraining the membership of zope.schema List and Set; is it
valid to say that this will work:


value=List(
  title=uValue,
  constraint=classProvides(IMyClass)
)


where IMyClass defines the schema for the MyClass and is the only
objects allowed in the List?

Thanks,
Tim




-- 
**
Join the OSHIP project.  It is the standards based, open source
healthcare application platform in Python.
Home page: https://launchpad.net/oship/ 
Wiki: http://www.openehr.org/wiki/display/dev/Python+developer%27s+page 
**


signature.asc
Description: This is a digitally signed message part
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Set List constraints

2008-07-10 Thread Markus Kemmerling

Am 10.07.2008 um 16:44 schrieb Tim Cook:


When constraining the membership of zope.schema List and Set; is it
valid to say that this will work:


value=List(
  title=uValue,
  constraint=classProvides(IMyClass)
)


where IMyClass defines the schema for the MyClass and is the only
objects allowed in the List?


I would rather say:

value=List(
  title=uValue,
  value_type=Object(schema=IMyClass)
)

Anyhow, such a constraint is of limited use only, since it does not  
prevent you from adding any object you like to the list *after* it  
got assigned to the 'value' attribute.


Regards,
Markus Kemmerling
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Set List constraints

2008-07-10 Thread Tim Cook

On Thu, 2008-07-10 at 16:59 +0200, Markus Kemmerling wrote:

 I would rather say:
 
 value=List(
title=uValue,
value_type=Object(schema=IMyClass)
 )

Can you elaborate why?


 
 Anyhow, such a constraint is of limited use only, since it does not  
 prevent you from adding any object you like to the list *after* it  
 got assigned to the 'value' attribute.

Okay, but that would be badly behaved code; correct?

In my implementation I am creating instances and committing them to a
ZODB repository.   My thoughts were that copies of those instances would
continue to constrain the types allowed in that attribute.  Is that
incorrect?

Cheers,
Tim




-- 
**
Join the OSHIP project.  It is the standards based, open source
healthcare application platform in Python.
Home page: https://launchpad.net/oship/ 
Wiki: http://www.openehr.org/wiki/display/dev/Python+developer%27s+page 
**


signature.asc
Description: This is a digitally signed message part
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Set List constraints

2008-07-10 Thread Markus Kemmerling

Am 10.07.2008 um 21:56 schrieb Tim Cook:



On Thu, 2008-07-10 at 16:59 +0200, Markus Kemmerling wrote:


I would rather say:

value=List(
   title=uValue,
   value_type=Object(schema=IMyClass)
)


Can you elaborate why?


You want to restrict the elements of a list to instances that provide  
a given interface IMyClass, right? That's exactly what a field's  
value_type attribute is for: It validates every element in a sequence  
or, more generally, a collection, before setting it. When you set the  
value_type to Object(schema=IMyClass) a validation error,  
SchemaNotProvided, will be raised for every list element not  
providing IMyClass (which in turn will raise a WrongContainedType  
error for the list itself).


The (rarely used) classProvides you used in your code example:


value=List(
  title=uValue,
  constraint=classProvides(IMyClass)
)



is meant to be used in class definitions to declare that a class  
itself -- not is instances -- provides a given interface.



Anyhow, such a constraint is of limited use only, since it does not
prevent you from adding any object you like to the list *after* it
got assigned to the 'value' attribute.


Okay, but that would be badly behaved code; correct?


Probably.  But then I would consider using a tuple instead of a list  
(and a frozenset instead of a set).



In my implementation I am creating instances and committing them to a
ZODB repository.   My thoughts were that copies of those instances  
would

continue to constrain the types allowed in that attribute.  Is that
incorrect?


I am not sure if I get this. If you set an instance of a mutable type  
like a list as an attribute of some other instance described by a  
schema, it will be validated, but still remain mutable (finally your  
other object only holds a reference to your mutable). It doesn't  
matter if it is persistent or not, or if it was copied before. But I  
might misunderstand your intention here.


Regards,
Markus Kemmerling

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users