Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Hi Dan, On Sat, 2009-01-17 at 01:28 +0300, Dan Korostelev wrote: Hi Tim. Unfortunately I didn't follow the discussion lately, so may be the problem is no more, but... There has been a tremendous amount of help from folks like you. However there is still not a solution. I have been asked several times for a 15 minute overview. This is tough given the complexity but allow me to ask the question at a more basic level. I believe it is similar to the way I asked it last year, but here goes. I'm not going to address Field or Object here, just explain the basics. class DataStructure(Persistence): abstract class class ItemStructure(DataStructure): abstract class class ItemList(ItemStructure): u Logical list data structure, where each item has a value and can be referred to by a name and a positional index in the list. The list may be empty. items = List( value_type=Object(schema=IElement), title=_(uitems), description=_(uPhysical representation of the list.), required=False ) class ItemTable(ItemStructure): u Logical relational database style table data structure, in which columns are named and ordered with respect to each other. Implemented using Cluster-per-row encoding. Each row Cluster must have an identical number of Elements, each of which in turn must have identical names and value types in the corresponding postions in each row. Some columns may be designated 'key' columns, containing key data for each row, in the manner of relational tables. This allows row-naming, where each row represents a body site, a blood antigen etc. All values in a column have the same data type. Used to represent any data which is logically a table of values, such as blood pressure, most protocols, many blood tests etc. Not used for time-based data, which should be represented with the temporal class HISTORY.. The table may be empty. class ItemSingle(ItemStructure): u Logical single value data structure. Used to represent any data which is logically a single value, such as a person's height or weight. * There are others and I left out the attributes and methods of these classes; with the exception of ItemList attribute 'items', where it is a zope.schema List but the value types are restricted to the schema described by IElement (also part of openEHR); but I think you get the idea. These classes are used as the base software for all openEHR applications. Of course the classes get more complex and deal directly with healthcare related issues. Now there are thousands of applications that will have data instance with attributes expressed in classes based on the above software that represent single (but complete) clinical concepts. But not all application user interfaces will use all available attributes of the concept. One may use an ItemTable and another an ItemList but they will both be valid in ANY application because the attribute represents a legal instance of ItemStructure. When that data instance is sent from application to another the receiving applications still needs to know the complete semantic context of when that data was collected.Think medico-legal, research and decision support over the lifetimes of patients and populations. So even if the user didn't see all the options in their GUI; it is still all contained in the data that was transfered. So how do I build my schemas so that Zope does the validation of nested schemas and even lets me use standard widgets? I hope this was less than 15 min. For those that want specific examples I can list a few. Cheers, Tim attachment: oe_trick.png 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] [Zope-dev] Next Step to Bug Resolution???
Hey, To debug this problem, a developer will need the smallest possible example of code that demonstrates the problem. That means, I take it, just 2 schemas and a single form. Describe briefly what you expect to happen and what in fact happens. If that example can be done *without* inheriting from Field that'd be good, as it is true that Field is only to be used inside a schema definition and once someone sees that we'll conclude that's the cause of the problem even though it might not be. It is interesting that in table 4.1 of Philipp W's book it specifically states that Field is the base class for all other fields. So how does one build fields that are noot part of the standard zope.schema? Yes, you do create new schema fields by subclassing from Field. It's just that we saw you putting a field not in a schema but in what looked like a concrete object. Perhaps we were wrong in reading your code, and this is one reason why you should come up with a minimum example that demonstrates the problem and only that, without a lot of distracting code surrounding it. You're the best suited person to actually create a minimum example. Regards, Martijn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Thanks for all the assistance. On Fri, 2009-01-16 at 18:05 +0100, Martijn Faassen wrote: Yes, you do create new schema fields by subclassing from Field. It's just that we saw you putting a field not in a schema but in what looked like a concrete object. This has given me a BIG pause while I'm working on a simpler example. It may actually solve the problem. Are you saying that in order to create a Field that can be used as an attribute of another class; I should define it in an interface and ONLY in an interface? Such like pseudo: import Field class IAbc(Interface) myNewField = Field( and then when I need to use it in a class, simply state that that class implements(IAbc)? If this is true I have a two month hard core re-factoring to do. Cheers, Tim Perhaps we were wrong in reading your code, and this is one reason why you should come up with a minimum example that demonstrates the problem and only that, without a lot of distracting code surrounding it. You're the best suited person to actually create a minimum example. Thanks again. 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* ** 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] [Zope-dev] Next Step to Bug Resolution???
Hi there, On Fri, Jan 16, 2009 at 7:02 PM, Tim Cook timothywayne.c...@gmail.com wrote: Thanks for all the assistance. On Fri, 2009-01-16 at 18:05 +0100, Martijn Faassen wrote: Yes, you do create new schema fields by subclassing from Field. It's just that we saw you putting a field not in a schema but in what looked like a concrete object. This has given me a BIG pause while I'm working on a simpler example. It may actually solve the problem. Are you saying that in order to create a Field that can be used as an attribute of another class; I should define it in an interface and ONLY in an interface? You should define a field as a subclass of Field (or of some more specific Field). When you want to actually use the field you created, you can only do so in an interface: class MyField(Field): pass class IMySchema(Interface): a = MyField(...) You cannot store fields on concrete objects. You must have an attribute on the concrete object that implements IMySchema that is named the same as the field and is of the format defined by the field (thus, a unicode string for a schema.Text field, and a list for a schema.List field). Regards, Martijn ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Hi Shane, On Tue, 2009-01-13 at 14:10 -0700, Shane Hathaway wrote: Sorry, but the patch doesn't make any sense. Your version of _validate_fields quietly skips validation entirely by default. First of all that is why I asked for others to look at it. :-) But I DID test it by inserting an incorrect schema and it did throw the correct error. I think it was the ShemaNotImplemented error. This was a few weeks ago but I can repeat it if needed. As I explained before; when one schema is checked by _validate_fields then all is well. The parameter 'errors' is None. Then errors is set to an empty list and any possible error msgs are appended. BUT when a schema has to check another schema because they are chained. 'errors' is already an empty list but even though the parameter errors is None a new list is appended to the first pass errors. This creates the msg WrongContainedType: [, []] because it IS a WrongContainedType because there is an empty list inside the original list. 'errors' is returned from _validate_fields back to the _validate method of the Object class where it is simply tested to see if it is empty. On this second pass it ISN't empty. It has another list inside so it fails the truth test and incorrectly throws an error. Look at the __repr__ method of the ValidationError class in the _bootstrapinterfaces.py module of the zope.schema package. This method was designed to generate short error messages, but in your case it appears to be truncating the error messages altogether. I would start by changing that particular __repr__() method to: def __repr__(self): return '%s(%s)' % (self.__class__.__name__, repr(self.args)) This version prefers verbosity. At a minimum, I hope this version of __repr__ will change the bizarre message zope.schema.interfaces.WrongContainedType: [, []] into something legible. It is more verbose. But I'm afraid it exhibits the same behavior as described above. Here are the results: in _validate raise WrongContainedType(errors) WrongContainedType: [RequiredMissing(()), WrongContainedType(([RequiredMissing(())],))] Note the empty parens. Now if I introduce bad code I get: in _validate raise WrongContainedType(errors) WrongContainedType: [RequiredMissing(()), SchemaNotProvided(())] SchemaNotProvided is correct. Though there isn't much else to go on but the full traceback points me to the right place. *** Shane, I think that so much of this is no longer useful. Right not now I'll go back and read all the obscure documentation (for the upteenth time) and see if it makes more sense now. I am very confused about thee use cases between creating Fields and using the Object(schema=Ischema) approach. Thanks for your help. --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* ** 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] [Zope-dev] Next Step to Bug Resolution???
Thanks All, On Fri, 2009-01-16 at 21:55 +0100, Carsten Senger wrote: Sure you can have specialized fields that subclass from Field, TextLine, or another base class. E.g. RegistrationNumber(TextLine) that takes care to validate the input for a special format. But you use them in an interface class, not the class that implements the interface. Okay. I got this down now. I still have a problem with understanding the use cases for using attribute=Object(schema=IMySchema ... But now all of the docs may make mmore sense with all I've leearned to past few days. Cheers, Tim 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] [Zope-dev] Next Step to Bug Resolution???
On Fri, 2009-01-09 at 11:02 +, Chris Withers wrote: Hi Chris, Thanks for the opportunity to address these issues. Hang on, you're making out this project of yours is some big deal, Well, it is kind of a big deal in healthcare. Simplistix (and others) may be interested in the fact that the UK NHS CfH project (the world's largest heathcare project) is using this technology in it's infrastructure. and yet when questioned on whether you use sane development practises, you throw your hands up in the air... H, somehow I think that this is a misunderstanding. If anyone is developing any kind of serious project, even as a ZCA user, I'd expect them to have automated unit tests with execellent coverage. If you don't, then your project starts to look pretty weak. Our project (OSHIP) *DOES* have unit tests that are comprehensive. Remember that my complaint is about the ZCA not covering all test cases; i.e. multiple Object fields simply return and empty list AS AN ERROR when there really isn't an error at all. This means that the ZCA tests do not fully cover the cases. If you are expecting ZCA users to be full time Python gurus then why have two mailing lists? zope-dev is for the development *of* the zope libraries zope3-users is for people developing software *with* the zope libraries. ... and that is why I started my question as a ZCA user but then went to the development list because the issue is obviously a ZCA core issue. I have received some other off-list advice and I do appreciate their input. One interesting comment was that this cannot be understood in 15 minutes (probably my lack of ability to explain it) and that being such an edge case it is on me to supply the complete solution. Fortunately, we have received funding for a project based on this framework and I will place this issue at the forefront. Thanks to the ZCA community for enduring my rants and hopefully in the coming weeks we can contribute to the zope.schema code and test cases that will exercise this demon. Cheers, 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* ** 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] [Zope-dev] Next Step to Bug Resolution???
Tim Cook wrote: Hi Chris, On Fri, 2008-12-19 at 10:06 +, Chris Withers wrote: Tim Cook wrote: As I said before I may have miss-diagnosed the problem and may fix may break other things? This is what a full-coverage unit and functional test suit is for. You have got automated tests for all this stuff, right? NO! I do not! I am a ZCA user not a full time python programmer. That is why I a asking for help here. Initially at least on the Zope Users list. Hang on, you're making out this project of yours is some big deal, and yet when questioned on whether you use sane development practises, you throw your hands up in the air... If anyone is developing any kind of serious project, even as a ZCA user, I'd expect them to have automated unit tests with execellent coverage. If you don't, then your project starts to look pretty weak. If you are expecting ZCA users to be full time Python gurus then why have two mailing lists? zope-dev is for the development *of* the zope libraries zope3-users is for people developing software *with* the zope libraries. cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Tim Cook wrote: Thanks Dieter, On Fri, 2008-12-19 at 19:41 +0100, Dieter Maurer wrote: I often approach situations like this with so called Monkey Patches: I replace or enhance classes or methods during startup (triggered by some startup event). This may not be optimal but allows me to solve my problems without tight coupling with the core developpers who usually do not have my problems and tend not see them as very high priority. I am starting to see why other Python developers aren't too interested in Zope. Despite the awesome power of the architecture. I've been poking around and using and supporting Zope since 1999. But because I am not an expert programmer (my skills are in another field) and because I do not know Zope inside and out. I am being chastised for not supplying my own complete fixes to the developers or at least being able to cover for their mistakes inside my application. Silly me. Working in open source for 14 years and I had no idea it worked like this. I'm sure glad that we do not run openEHR like that. This seems a little unfair. By my count you have had five responses, four of which have been friendly and helpful. Don't be discouraged by the occasional dragon! Laurence ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Tim Cook wrote: As I said before I may have miss-diagnosed the problem and may fix may break other things? This is what a full-coverage unit and functional test suit is for. You have got automated tests for all this stuff, right? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [Zope-dev] Next Step to Bug Resolution???
Hi Chris, On Fri, 2008-12-19 at 10:06 +, Chris Withers wrote: Tim Cook wrote: As I said before I may have miss-diagnosed the problem and may fix may break other things? This is what a full-coverage unit and functional test suit is for. You have got automated tests for all this stuff, right? NO! I do not! I am a ZCA user not a full time python programmer. That is why I a asking for help here. Initially at least on the Zope Users list. If you are expecting ZCA users to be full time Python gurus then why have two mailing lists? It seems that you are asking a user to provide the developers with a ready to commit patch. I wish I had those skills and could do so. Alas, it isn't going to happen. Cheers, 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* ** 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] [Zope-dev] Next Step to Bug Resolution???
Thanks Dieter, On Fri, 2008-12-19 at 19:41 +0100, Dieter Maurer wrote: I often approach situations like this with so called Monkey Patches: I replace or enhance classes or methods during startup (triggered by some startup event). This may not be optimal but allows me to solve my problems without tight coupling with the core developpers who usually do not have my problems and tend not see them as very high priority. I am starting to see why other Python developers aren't too interested in Zope. Despite the awesome power of the architecture. I've been poking around and using and supporting Zope since 1999. But because I am not an expert programmer (my skills are in another field) and because I do not know Zope inside and out. I am being chastised for not supplying my own complete fixes to the developers or at least being able to cover for their mistakes inside my application. Silly me. Working in open source for 14 years and I had no idea it worked like this. I'm sure glad that we do not run openEHR like that. Cheers, 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* ** 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