Re: [Zope3-Users] Re: zope.schema Question
On Mon, 2008-07-07 at 00:46 +0200, Philipp von Weitershausen wrote: description=Object( schema=IFoo, ... ) So the zope.schema.Object field is really about specifying objects that provide a certain schema. It's not for *arbitrary* objects (use zope.schema.Field or zope.interface.Attribute here). Thanks Philipp. Field doesn't work because it expects a unicode type. Attribute works but I would like to be able to flag it as 'required' which is not part of the Attribute class. Object would work if it would allow types that subclass from the schema given. A concrete example: IItemStructure(Interface) IItemTree(IItemStructure) IItemTable(IItemStructure) ... ItemTree(ItemStructure) implements(IItemTree) ItemTable(ItemStructure) implements(IItemTable) ... Now I want to allow description to be any descendant of ItemStructure. So I had hoped that: description=Object( schema=IItemStructure, title=_(uDescription), description=_(uDescription of the activity.), required=True, ) would provide that functionality. It still throws a WrongTypeError. I feel like the answer lies somewhere in the zope.interface.implement* functions but I lack the Zen to get the right combination. Thanks, 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] Re: zope.schema Question
El 7 Jul 2008, a las 09:20 , Tim Cook escribió: On Mon, 2008-07-07 at 00:46 +0200, Philipp von Weitershausen wrote: description=Object( schema=IFoo, ... ) So the zope.schema.Object field is really about specifying objects that provide a certain schema. It's not for *arbitrary* objects (use zope.schema.Field or zope.interface.Attribute here). Thanks Philipp. Field doesn't work because it expects a unicode type. I think you'll find that that's wrong. Field describes a generic attribute, much like z.i.Attribute. Attribute works but I would like to be able to flag it as 'required' which is not part of the Attribute class. Right. Use Field for that :). Object would work if it would allow types that subclass from the schema given. A concrete example: IItemStructure(Interface) IItemTree(IItemStructure) IItemTable(IItemStructure) ... ItemTree(ItemStructure) implements(IItemTree) ItemTable(ItemStructure) implements(IItemTable) ... Now I want to allow description to be any descendant of ItemStructure. So I had hoped that: description=Object( schema=IItemStructure, title=_(uDescription), description=_(uDescription 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. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Zope Product Recommendations
Hi all, The list of products at Zope.org is fairly daunting for a n00b like me. Does anyone have any recommendations in terms of usefulness / wow factor / day to day utility apps? Cheers, Jon Hadley http://jon-hadley.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: zope.schema Question
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=_(uDescription), description=_(uDescription 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* ** 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] Re: zope.schema Question
El 7 Jul 2008, a las 12:06 , Tim Cook escribió: 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? Yes, it constraints the value of the 'description' attribute to any object that provides IItemStructure. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Cannot install Zope 3.3.0 as a Windows Service
I am installing this on Windows XP, Service Pack 2 Hello, I am looking for some help installing Zope 3.3.0 as a Windows service. When I run the C:\Zope\Instance\3.3.0python bin\zopeservice.py --startup auto install I get a message I placed in the paste http://paste.lisp.org/display/63370. I tried Zope IRC and I have looked in the Zope book and searched on line, but can't find anyone with this problem. Any suggestions are greatly appreciated Here is the message I pasted. C:\Zope\Instance\3.3.0python bin\zopeservice.py --startup auto install Traceback (most recent call last): File bin\zopeservice.py, line 84, in ? from zope.app.winservice.service import Service ImportError: No module named winservice.service Thanks, Joe Bigler ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Cannot install Zope 3.3.0 as a Windows Service
Hi Joe, Plone is based on zope2 (though it uses nowadays a lot of zope3 packages also). On Windows I usually avoid having both Plone/Zope2 and Zope 3. Most probably zope 3 and zope 2 are conflicting in this case due to which you are not able to see from zope.app.winservice.service import Service which is a zope3 class. My usual configuration on Windows is: - Python 2.4 - Python for Windows extensions - Zope 3 - Other Python packages which don't conflict with zope 3. (PIL, reportlab etc.) With regards, - Shailesh On 7/7/08, Joe Bigler [EMAIL PROTECTED] wrote: Hi Shalesh, Thanks for the reply, Yes, I installed python 2.4 pywin32-211 I did not use eggs or buildout. I can start it with runzope.bat Here is what I see in the ZMI under Runtime information Runtime Information Server Control Database Schemas ZODB Control Translation Domains Registration * Errors * Undo! * Undo more * Undo all * Help Uptime 0 day(s) 02:00:09 System platform Windows chm036 XP 5.1.2600 Zope version 3.3.0 Python version 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] Command line C:\Zope\Instance\3.3.0\bin\runzope Preferred encoding cp1252 FileSystem encoding mbcs Process id 2272 Python path * C:\Zope\Instance\3.3.0\lib\python * C:\Zope\2.9.8\Python\Lib\site-packages * C:\Zope\Instance\3.3.0\bin * C:\Program Files\Plone2.5.5\Python\lib\site-packages\setuptools-0.6c7-py2.4.egg * C:\Program Files\Plone2.5.5\Python\lib\site-packages\archgenxml-2.0-py2.4.egg * C:\ArchGenXML\src * C:\Program Files\Plone2.5.5\Zope\lib\python * C:\Program Files\Plone2.5.5\Python\python24.zip * C:\Zope\Instance\3.3.0\bin * C:\Program Files\Plone2.5.5\Python\DLLs * C:\Program Files\Plone2.5.5\Python\lib * C:\Program Files\Plone2.5.5\Python\lib\plat-win * C:\Program Files\Plone2.5.5\Python\lib\lib-tk * C:\Program Files\Plone2.5.5\Python * C:\Program Files\Plone2.5.5\Python\lib\site-packages * C:\Program Files\Plone2.5.5\Python\lib\site-packages\PIL * C:\Program Files\Plone2.5.5\Python\lib\site-packages\win32 * C:\Program Files\Plone2.5.5\Python\lib\site-packages\win32\lib * C:\Program Files\Plone2.5.5\Python\lib\site-packages\Pythonwin * C:\Program Files\Plone2.5.5\Python\lib\site-packages\wx-2.6-msw-ansi -- *From:* Shailesh Kumar [mailto:[EMAIL PROTECTED] *Sent:* Monday, July 07, 2008 9:54 AM *To:* Joe Bigler *Subject:* Re: [Zope3-Users] Cannot install Zope 3.3.0 as a Windows Service Do you have Python for Windows extensions installed? You may get it from : http://sourceforge.net/projects/pywin32/ - Shailesh On 7/7/08, Joe Bigler [EMAIL PROTECTED] wrote: I am installing this on Windows XP, Service Pack 2 Hello, I am looking for some help installing Zope 3.3.0 as a Windows service. When I run the C:\Zope\Instance\3.3.0python bin\zopeservice.py --startup auto install I get a message I placed in the paste http://paste.lisp.org/display/63370. I tried Zope IRC and I have looked in the Zope book and searched on line, but can't find anyone with this problem. Any suggestions are greatly appreciated Here is the message I pasted. C:\Zope\Instance\3.3.0python bin\zopeservice.py --startup auto install Traceback (most recent call last): File bin\zopeservice.py, line 84, in ? from zope.app.winservice.service import Service ImportError: No module named winservice.service Thanks, Joe Bigler ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: zope.schema Question
Answering my own questions: On Mon, 2008-07-07 at 10:20 -0300, Tim Cook wrote: All of my source files have the unicode declaration: # -*- coding: utf-8 -*- as the first line. Do those strings inside the list have to be marked as unicode? for example: [([u'include', ([([u'archetype_id/value', ([u'/disposition\\.v1draft/'], {})], {})], {})], {})] After flattening the nested construct and unicode converting the strings: [u'include', u'archetype_id/value', u'/disposition\\.v1draft/'] Same problem. If so; if I remove the unicode declaration will that prevent this error? Nope! Now I don't know where to search for the problem. Any ideas? -- 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
SOLVED! Re: [Zope3-Users] Re: zope.schema Question
... and I've learned a lot thanks to you patience. On Mon, 2008-07-07 at 12:41 -0300, Tim Cook wrote: I've been Googling for a script I can run against all of my source to test characters for unicode just in case there are more of those that I copied into title or description fields. If you think of anything let me know. Otherwise I may have to write one. So I wrote one and sure enough there was a non-printing non-unicode character in a description string. --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
Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, 2008-07-07 at 13:58 -0300, Tim Cook wrote: ... and I've learned a lot thanks to you patience. On Mon, 2008-07-07 at 12:41 -0300, Tim Cook wrote: I've been Googling for a script I can run against all of my source to test characters for unicode just in case there are more of those that I copied into title or description fields. If you think of anything let me know. Otherwise I may have to write one. So I wrote one and sure enough there was a non-printing non-unicode character in a description string. Seems I was a little premature. There was the character but I forgot about a change I had made that caused the real problem not to show up. It's still there. Sigh; back to the search. --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: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, Jul 7, 2008 at 1:28 PM, Tim Cook [EMAIL PROTECTED] wrote: Okay, the problem is defined but it really isn't a solution for me. It seems that Zope has defined 'description' as a keyword not allowed in schema definitions. That's rather odd. Can you construct a small example (say, a stand-alone .py file) that demonstrates the problem? -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, 2008-07-07 at 13:34 -0400, Benji York wrote: On Mon, Jul 7, 2008 at 1:28 PM, Tim Cook [EMAIL PROTECTED] wrote: Okay, the problem is defined but it really isn't a solution for me. It seems that Zope has defined 'description' as a keyword not allowed in schema definitions. That's rather odd. Can you construct a small example (say, a stand-alone .py file) that demonstrates the problem? Okay. But before I do that. Is my approach to initializing an instance correct or is the problem the way I handled the keywords? class Activity(Locatable): A single activity within an instruction. implements(IActivity) def __init__(self,descr,tim,atid,nodeid,**kw): self.descript=descr self.timing=tim self.actionArchetypeId=atid self.__name__=nodeid for n,v in kw.items(): setattr(self,n,v) Thanks, 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: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, Jul 7, 2008 at 2:25 PM, Tim Cook [EMAIL PROTECTED] wrote: Okay. But before I do that. Is my approach to initializing an instance correct or is the problem the way I handled the keywords? ... for n,v in kw.items(): setattr(self,n,v) There are people who like this style and people who don't (and consider it ridiculously fragile), but zope.schema couldn't care less about this. -Fred -- Fred L. Drake, Jr. fdrake at gmail.com Chaos is the score upon which reality is written. --Henry Miller ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, 2008-07-07 at 13:34 -0400, Benji York wrote: On Mon, Jul 7, 2008 at 1:28 PM, Tim Cook [EMAIL PROTECTED] wrote: Okay, the problem is defined but it really isn't a solution for me. It seems that Zope has defined 'description' as a keyword not allowed in schema definitions. That's rather odd. Can you construct a small example (say, a stand-alone .py file) that demonstrates the problem? Okay, this demonstrates the problem. But now I know it's my code. Benji may recall answering another problem I had with: zope.interface.exceptions.InvalidInterface: Concrete attribute, Where he said one of the class didn't but should inherit from Field. So, I now have several ancestor classes (all the ones that used to inherit from object) that now inherit from Field. It appears I was careless in making these choices. If TestB inherits from Field and TestA inherits from object (current state) or both inherit from Field the problem appears. If TestB inherits from object and TestA inherits from Field or both inherit from object or you change the name of the TestB.description attribute the error goes away. Now it is probably obvious by now that I have no idea what is going on here so if someone has time to add a little Zen i would appreciate it since it will help me unscrew my inheritance tree. :-) Cheers, Tim --- # descr.py -- test behaviour of the Zope schema when using field names as class attributes. from zope.interface import Interface,implements from zope.schema import Field,Object class ITestA(Interface): one=Field( title=uone, description=uone ) class TestA(object): def __init__(self,num): self.one=num class ITestB(Interface): two=Field( title=utwo, description=utwo ) description=Object( schema=ITestA, title=udescrption, description=udescription ) class TestB(Field): def __init__(self,num,descr): self.two=num self.description=descr def buildit(): a=TestA(1) print a.one b=TestB(2,a) print b.two print b.description if __name__ == __main__: buildit() --- # descr.py -- test behaviour of the Zope schema when using field names as class attributes. from zope.interface import Interface,implements from zope.schema import Field,Object class ITestA(Interface): one=Field( title=uone, description=uone ) class TestA(object): def __init__(self,num): self.one=num class ITestB(Interface): two=Field( title=utwo, description=utwo ) description=Object( schema=ITestA, title=udescrption, description=udescription ) class TestB(Field): def __init__(self,num,descr): self.two=num self.description=descr def buildit(): a=TestA(1) print a.one b=TestB(2,a) print b.two print b.description if __name__ == __main__: buildit() 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] Re: A slew of z3c.form questions
Stephan Richter wrote: On Sunday 06 July 2008, Martin Aspeli wrote: I'm guessing z3c.form groups do that, of course, but it's not clear to me whether it's appropriate to use them for this kind of thing, especially since the logical groupings and field ordering will only be calculable at runtime. Groups were written to support your use case specifically. I think they even put fieldset tags around each group, but I would have to check the template. Heh, indeed. Though now that I see it, I notice that it's using the non-existent fieldgroup tag, rather than fieldset. I realise it's mostly used in the test, but you may want to fix that. :-) One other question: I want the Group's to be instantiated and populated at run time. That is, I don't want a class for each one, but rather I want to be able to distribute fields across groups via various adapters looked up by the form. Is this sensible? Should I instantiate Group objects directly and set their fields etc? Or should I do something else? Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users