Re: [Zope3-Users] Views for adapted components
On Monday 26 March 2007 12:57:58 pm FB wrote: Hi, On Mon, Mar 26, 2007 at 12:43:21PM +0200, Lorenzo Gil Sanchez wrote: [snip] This is not so bad. The real problem is that I have to modify the original IMyCompoment component to tell zope it implements IImportExport even when this is false. The adapter does it, not the compoment. But I don't know other way to make my view work with my components. What you trying to do sounds reasonable at the first moment, but it would be impossible to accomplish. You try to create an (warning: self invented expression :-) ) Adaption chain: object - some_adapter - view which is something, zope doesn't support. Think about it: the publisher would have to check each possible adapter for a given object trying to create views for it - and this is just a 2-adaption-chain... . However, there's an easy solution: Write a view like that: page name=im-and-export.html for=zope.app.container.interfaces.IContained [...] class=.view.ImExPortView menu=zmi_views title=Im-Export / class ImExPortView(object): def __call__(self): try: export=IImportExport(self.context) except: raise NotImportableException(self.context) [...] Another way to do this, if you don't like exceptions is (in your view): adapter = IImportExport(self.context, None) if adapter is not None: do something else: raise an exception or do something other Cheers -Tom Regards, Frank ___ 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] zope.schema.Object - Object of Objects
Christian Lueck wrote: ... Since there is not yet a posting on this problem on the list I decided to post it. Maybe this is a zope3-newbie problem, but maybe this list is the right place for these kinds of problems. I'm starting out on some new Zope3 work and would appreciate 'recipes' to look at. Perhaps adding these to a site such as zopelabs.com would (also) be useful. There is a Zope3 category there, but unfortunately only has zero items. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Disappearing dictionary. Upon restart, dictionary resets.
Alec Munro wrote: Well, I narrowed it down a little bit more. I've been initializing the dictionary in the class declaration, like the following: class SomeObj: some_dictionary = PersistentDict({}) Now, for some reason, each time Zope was started, it called this, and whenever I tried to access the some_dictionary propery on any of my objects, it returned the newly created one. Is this what should be happening? That's the case in zope and python, 'some_dictionary' attribute is mutable. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Problems with a catalog
1. How do I add a catalog to a site ? 2. Catalog error 1/- I get thus far.. From the /++etc++site/@@SiteManagement form I can successfully add a Catalog object. However, when I try to add an index, it fails ... File ... /zope/app/catalog/catalog.py, line 130, in indexAdded File ... /zope/app/catalog/catalog.py, line 68, in updateIndex File ... /zope/component/__init__.py, line 257, in getUtility ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') Then if I try to add an IntId Tool, it fails ... File ... app/catalog/catalog.py, line 144, in reindexDocSubscriber File ... component/__init__.py, line 257, in getUtility ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') Actually, attempting to add any other object no longer works with the same error. So the catalog depends on a/the intid utilitly. When I add a uid utility first, then a catalog, adding and index still fails (as above). 2/ However, if I add the IntId utility to /++etc++/default (rather than /++etc++/tools), I can add a catalog, then successfully create index(es). However when I try to search the catalog it fails.. cat = zapi.getUtility(ICatalog, context=root) print cat.searchResults() None print cat.searchResults(title_index='') Traceback (most recent call last): File stdin, line 1, in ? File ... /zope/app/catalog/catalog.py, line 107, in searchResults File /usr/lib/python2.4/site-packages/PIL/__init__.py, line 257, in getUtility zope.component.interfaces.ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') (Don't know why PIL is appearing in the traceback.) I can make it work if I change (catalog.py:107) from: uidutil = zapi.getUtility(IIntIds) to: uidutil = zapi.getUtility(IIntIds, context=self) cat = zapi.getUtility(ICatalog, context=root) cat.searchResults(title_index='') zope.app.catalog.catalog.ResultSet instance at 0x41ac168c I don't know why the context needs to be explicitly set. Is it something to do with how the IntIds/Calatogs should be added to the site? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Adding indexes to a Catalog tool subclass
I can add a tool which is a simple subclass of Catalog. However if I try to add some index(es) in the constructor it fails with a NotYet error (see below). Is there a simple way to achieve this? from zope.app.catalog.interfaces import ICatalog from zope.app.catalog.catalog import Catalog from zope.app.catalog.text import TextIndex class IFoodCatalog(ICatalog): pass class FoodCatalog(Catalog): implements(IFoodCatalog) def __init__(self): super(FoodCatalog, self).__init__() #this fails #self['title'] = TextIndex('title', IFood) File .. /zope/app/intid/__init__.py, line 161, in addIntIdSubscriber File .. /zope/interface/interface.py, line 697, in __call__ File .. /zope/interface/interface.py, line 765, in __adapt__ File .. /zope/app/component/hooks.py, line 96, in adapter_hook File .. /zope/interface/adapter.py, line 419, in adapter_hook File .. /app/security/adapter.py, line 88, in __call__ File .. /zope/app/keyreference/persistent.py, line 41, in __init__ NotYet: zope.app.catalog.text.TextIndex object at 0x4264c36c ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Adding indexes to a Catalog tool subclass
Gary Poster wrote: On Sep 28, 2005, at 1:53 AM, Tom Dossis wrote: I can add a tool which is a simple subclass of Catalog. However if I try to add some index(es) in the constructor it fails with a NotYet error (see below). Is there a simple way to achieve this? Yes. Don't add the indexes with the constructor. Add the catalog as a full utility first, as I described in my previous email, then start adding indexes. An interesting observation .. 1. Adding content into a container in the constructor does work... 2. Adding a Unique Id Utility will stop it working (NotYet error). e.g. class Contained(Persistent): implements(IContained) class Container(BTreeContainer): implements(IContainer) def __init__(self): super(Container, self).__init__() self[u'small'] = Contained() self[u'medium'] = Contained() self[u'large'] = Contained() Should this pattern be considered taboo in z3? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] object has no attribute '_SampleContainer__data'
Jim Fulton wrote: Tom Dossis wrote: Leticia Larrosa wrote: I get the following error: 'Service' object has no attribute '_SampleContainer__data' I implementend a simple subclass of SampleContainer, then changed to subclass BTreeContainer, but forget to delete existing instances created in Zope. A tell tale sign is you can no longer delete the broken instance(s) This sounds like a bug. Could you report this with a specific example? Jim I can remember exactly how I naively did this originally, but I can achieve it with a little sabotage.. class Bogus(BTreeContainer): pass ... bogus = Bogus() root['bogus'] = bogus = Bogus() del bogus.__dict__['_SampleContainer__data'] del root['f'] Traceback (most recent call last): : File .. /zope/interface/adapter.py, line 487, in subscribers subscribers = [subscription(*objects) File .. /zope/app/container/contained.py, line 177, in dispatchToSublocations for sub in subs.sublocations(): File .. /zope/app/container/contained.py, line 208, in sublocations for key in container: File .. /zope/app/container/sample.py, line 56, in __iter__ return iter(self.__data) AttributeError: 'Bogus' object has no attribute '_SampleContainer__data' Is this a bug because the container now fails to fulfill it's interface causing object propogation to fail? Is defensive programming desirable or appropriate? snippet1 from distpatchToSublocations subs = ISublocations(object, None) if subs is not None: for sub in subs.sublocations(): snippet2 from ContainerSublocations adapter def sublocations(self) container = self.container for key in container: yield container[key] -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: How do I logout from Zope 3 Management Interface
Todd Wilson wrote: I just joined the list, and I am following up on a post in the archive (sorry -- there wasn't a way to do this directly, so I don't know if this message will end up in the same thread). On 10/1/05, Lennart Regebro regebro at gmail.com wrote: On 10/1/05, Milind Khadilkar zedobject at gmail.com wrote: I have installed Zope 3.1 rc 3. After logging in, I could not find any logout button. There is no way to consistently log out from Basic HTTP authorization... Is it OK to directly shut the browser window ( I am using Firefox)? Yup. I am writing for clarification on Lennart's answer to Milind's question. In the many screenshots of the ZMI that can be seen in Philip von Weitershausen's book (Web Component Development with Zope 3, Springer, 2005), one can definitely see [Logout] in the upper-right corner of the ZMI page. Like Milind, however, my installation of Zope 3.1.0 does not have this link in its ZMI pages. Is the absence of [Logout] in the latest version(s) because the developers realized that it was misleading (as Lennart is suggesting) and best left off, or is there another reason? Given the sensitive nature of some Zope deployments, the management password seems very well worth protecting. How about using a secure login (e.g., https) and sessions, which is capable of supporting a true logout? You can try the pluggable auth util (PAU)... To add one to your site Manage Site - Site Management - Authentication (Unique Utilites) Add a Session Credentials Plugin Manage Site - tools - PluggableAuthentication Edit the form to add 'Session Credentials' and submit Change You'll now get a sessions based login form when you login to that site. But you'll now need a 'Authenticator Plugin' to get in ... you can add a Principal Folder Plugin to the PAU, then add principal(s) to it. To get a [Logout] link you'll need to add the following zcml directive.. adapter for=zope.publisher.interfaces.browser.IBrowserRequest factory=zope.app.security.LogoutSupported / As for the https you could use apache as a proxying front end. I believe the current dev. version of zope 3.2 uses twisted which may offer https services, but I know next to nothing about it. Hey I just realised I missed something, how do you assign roles to principles using a PrincipleFolder above? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] catalog woes
Pete Taylor wrote: Hi all, on a fresh install of zope3.1final, and then again when running from the latest update out of the Trunk, I end up with the following when I attempt to register a catalog: ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') I saw a similar post to this on the zope3-users list in sept sometime, but I wasn't working with catalogs then, so it didn't really stick out to me. url to the post is here http://mail.zope.org/pipermail/zope3-users/2005-September/001073.html. not exactly the same issue I'm running into, but close. Hi Pete, That's my posting. The catalog depends on an unnamed IntId utility. You first need to add and register (no name) a Unique Id utility in your ++etc++site/default site management folder. Then add your catalog(s) using the Site Management page. These end up in your ++etc++site/tools sm folder. If you need to do this programmatically I can send some code snippets based on the the response on my original posting (by Gary Poster). -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] fieldindex
Pete Taylor wrote: hi all, I have a catalog set up, and i've been able to make text field work on zmi-added content. however, what i really want to be able to index and search is a set of objects that are created and archived elsewhere. I've tried to add a field index with the interface set to the interface that my objects implement, and a field to an attribute (like 'name') of the object, with no luck. as a test, i tried to add a field index on IZopeDublinCore and use the field_name as title. still no luck. Hi Pete, And callable is off And tried it and worked for me. Aren't you seeing the doc. and word counts change in the catalog Advanced page as you add/del. objects? has anyone else had any experience with making field indexes work? Thanks as always, Pete ___ 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] at sea with basic setup
Ross Boylan wrote: I'd like to create some users, set authentication methods, and so on. After a lot of fooling around with the GUI and looking at various docs, I conclude I have no idea what's going on. To complicate matters, there were some issue with my installation on Debian (using the package in testing) so that some of the products aren't available. I wonder if any of them are key to getting things going. Do I need to create something like a Zope 2 user folder? Are all users defined in the principals file on disk? I tried installing a Site Manager object. The Site Management screen shows a lot of entries (e.g., Authenticator Plugin) that say there are no entries available yet. I installed some objects that seemed related, gave them names, and tried to hook them up with this screen. The only thing that seems to have worked is the unique id tool. Hi Ross, There's a related posting at.. http://mail.zope.org/pipermail/zope3-users/2005-October/001321.html The principal folder plugin provides something equivalent to a zope2 user folder in that you can manage principals from the zmi. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?
Dominik Huber wrote: subscriber for=.IYourObject zope.app.container.interfaces.IObjectAddedEvent handler=.addCatalogAndIndex / handler pseudo code: def addCatalogAndIndex(obj, event): sm = zapi.getNextSiteManager(obj) catalog = Catalog() addLocalUtility(sm, 'XY', ICatalog, catalog) catalog[name] = Index(name, IAnyInterface) Regards, Dominik From the apidoc for IWriteContainer.__setitem__(name, object) it states.. ''If an add event is generated and the object can be adapted to IObjectAddedEvent, then the adapter's addNotify method is called with the event.'' This could be alternative way to implement the the subscriber solution above. However, from looking at the code (Zope3.1) it doesn't seem to to what the apidoc claims. Does anybody know if this is still intended? -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] NameChooser functionality for IContainerNamesContainer
Joel Moxley wrote: I successfully added a name chooser for objects added through an add form to my container. This involved implementing IContainerNamesContainer on my container, INameChooser on my NameChooser, registering each, and being sure to set my set_before_add fields in the addform registration. What is The Right Way (tm) to use this NameChooser functionality outside of the addform? In other words, I have a method that defines the container from a file as follows: self[name] = obj This obviously would overwrite duplicates, etc. I would prefer to have something as follows which would use the NameChooser machinery automatically (ie, without having to get the NameChooser adapter in my method). Is there a way I can do something along the lines of this? self.add(obj) Maybe something like: class MyContainer.. .. def add(obj, name=''): name = INameChooser.chooseName(name, obj) self[name] = obj .. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] What attributes are made persistent
Peter Bengtsson wrote: def __init__(self): self.queue = {} self.queue seem is empty each time I restart Zope. That's because dictionaries are not derived from Persistent. Try PersistentDict. D'oh! That's confusing. Isn't there a class that gathers all of these in one. It seems confusing, you derive from Persistent but only some are accepted. Does that mean that there's PersistentFloat and PersistentTuple too? If not, why *only* dicts? No, this issue applies to mutable attributes.. self.a = 1.1 self.b = (1,2,3) self.b = (4,5,6) These will persist as is, because you're rebinding the attribute (reference) each time. However, for ... self.queue[1] = 2 This doesn't rebind self.queue. So another way you could 'persist' this change is .. self.queue[1] = 1 self.queue = self.queue ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Multiple sites in a single zope instance?
Graham Stratton wrote: What I want to be able to do is to simply create many 'sites' within a single instance. What matters is that each site can have its own appearance and users (editors). Now, I'm not sure that my sites actually need to be true Zope3 sites. Maybe I just need to have a marker interface at the top level of each of my sites, and that will be enough. Probably best to Make a Site. This will enable you to install utils into each site. This will also enable you set up resources specific to each site. This could be useful for your skinning requirements. But what I don't seem to have any way of doing is setting the appearance per site. I haven't looked at the users problem yet. You can install separate PAU's (Pluggable Auth. Util.) into each site to have different user bases for each site. Alternatively installing a PAU into a top level site enables you to share the user base across sites. I could set up multiple skins, and then change the skin by using apache rewrite rules. But both parts of this are quite hard and complex, and involve restarting both systems. I'd like to be able to set simple things about the appearance TTW. At this point I fear I'm going very wrong, but I'll continue anyway ;-) I'm guessing a little about how you want to set the appearance TTW... Write a utility to manage certain site skin config. and properties. Your skin can consult this utility to obtain appearance parameters/objects. Also the util. could make images/files (logo's, css) available as resources to your skin. regards -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] PyWebOff
Shane Hathaway wrote: Hello, I've been assigned to present Zope in a local upcoming Python user group meeting. As part of the assignment, I'm supposed to solve the PyWebOff challenge using Zope: http://pyre.third-bit.com/pyweb/challenge.html I'd like to do this using Zope 3. However, I'm really struggling. I feel like I must be using Zope 3 in a really dumb way, because the code so far is highly repetitive, completely dependent on Zope, and more XML than Python. This is not going to go over well in the presentation. Can anyone tell me how to do this better with Zope 3? Maybe my Zope 2 experience is preventing me from seeing something obvious. I've attached the __init__.py and configure.zcml that I created in a package called challenge. I agree, the __init__.py and configure.zcml are pretty dry reading. I reckon you could start your PUG presentation from the end (so to speak) by presenting one (or more) doctests. One you have your captive audience, then go the the start. Take a Test-Driven-Development approach. It's easy to disgest an application (and zope) in test case sizes. And as each need arise, bring in the appropriate ZCML to showcase it value. This may help distill the python, zope and zcml. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Principal annotations
Shane Hathaway wrote: Shane Hathaway wrote: Was this an accident? Did it work at one time? Are there plans to make principal annotation views work again? And how can I edit user annotations in the meanwhile? No one knows, I guess. After spending many days on a seemingly simple problem, I've drawn a blank. Not that I've tried this myself (yet). Re: the ZopeBook example, I'd change the annotation adapter from IPrincipal to IInternalPrincipal.. adapter factory=.info.PrincipalInformation provides=.interfaces.IPrincipalInformation for=zope.app.authentication.principalfolder.IInternalPrincipal permission=zope.ManageServices / I guess you'd also need to make the InternalPrincipal class annotatable, in your application configure.zcml, add... content class=zope.app.authentication.principalfolder.InternalPrincipal implements interface=zope.app.annotation.IAttributeAnnotatable / /content Also in the example the browser:editform directive should be changed from IPrincipal to IInternalPrincipal. Good luck. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Principal annotations
Tom Dossis wrote: Shane Hathaway wrote: Shane Hathaway wrote: Was this an accident? Did it work at one time? Are there plans to make principal annotation views work again? And how can I edit user annotations in the meanwhile? No one knows, I guess. After spending many days on a seemingly simple problem, I've drawn a blank. Not that I've tried this myself (yet). Re: the ZopeBook example, I'd change the annotation adapter from IPrincipal to IInternalPrincipal.. Alternatively, it may possible to setup an adapter for IInternalPrincipal to IPrincipal ? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Principal annotations
Shane Hathaway wrote: Alternatively, it may possible to setup an adapter for IInternalPrincipal to IPrincipal ? I tried that first, but it got messy. IPrincipal needs an id, but InternalPrincipal doesn't know its own id; only the folder that contains it knows. However, the folder has no method for giving me the id of an InternalPrincipal, so the encapsulation isn't complete. Maybe I should work harder in this direction anyway. zapi.getName(principal) will get the id managed by principal folder, e.g. site=root['mysite'] sm = site.getSiteManager() pf = sm['tools']['PluggableAuthentication']['PrincipalFolder'] pf zope.app.authentication.principalfolder.PrincipalFolder object at 0x419957ec list(pf) [u'1'] principal = pf['1'] principal zope.app.authentication.principalfolder.InternalPrincipal object at 0x4183d3ec from zope.app import zapi zapi.getName(principal) u'1' Your idea of annotating InternalPrincipals rather than Principals seems to work, but I apparently did something wrong, because edited annotations don't persist! I can save edits, but when I reload the page, they're gone. I don't know why. I seem to recall encountering a similar problem once before, but unfortunately can't remember the details. I do remember looking at the annotation code to work it out. Thanks for helping me over a hurdle. You'd think a Zope 2 veteran like me would have little trouble with Zope 3 Maybe that has something to do with it. We switched from zope2/cmf/plone to zope3 early on in the development of a new application. Interestingly the python-only programmer back then took to zope3 much easier than zope2/cmf/plone. get to know practically all of Zope 3 before I can really do anything with it. (I had to do the same thing with Zope 2.) I'm sure it will all click into place soon enough. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Principal annotations
Shane Hathaway wrote: Your idea of annotating InternalPrincipals rather than Principals seems to work, but I apparently did something wrong, because edited annotations don't persist! I can save edits, but when I reload the page, they're gone. I don't know why. A quick test, hope it helps... from zope.app.authentication.principalfolder import InternalPrincipal from zope.app.annotation import IAttributeAnnotatable from zope.interface import classImplements classImplements(InternalPrincipal, IAttributeAnnotatable) annotations = IAnnotations(principal) annotations {} from persistent.dict import PersistentDict annotations['mykey'] = PersistentDict() info = annotations['mykey'] info['abc'] = 123 import transaction transaction.commit() ^D site=root['f2l'] sm = site.getSiteManager() pf = sm['tools']['PluggableAuthentication']['PrincipalFolder'] principal = pf['1'] principal.__annotations__ BTrees._OOBTree.OOBTree object at 0x4190f974 principal.__annotations__['mykey'] persistent.dict.PersistentDict object at 0x4178496c principal.__annotations__['mykey']['abc'] 123 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Losely or rather, less loosely coupled objects.
Max M wrote: When doing sites in Zope 2 I often have the need to couple/contain two or more fixed objects. When an object needs to have some specific properites and logic, many developers choose to subclass an existing object and change that. Eg. a member folder needs to *allways* have a 'contact_info' object. Eg. to keep company policy and to ease skinning. That would typically lead to a new folderish content type with contact info properties. Which I think is a really bad pattern. Normally in Zope 2 I just give it a fixed id, and then set the folder._reserved_names = ('contact_info',) property on the parent folder. This is like folder.contacts_info = ContactInfo() But this is a pretty obscure and unknown feature. And site managers cannot use it. I have the suspicion that many cases where people are doing Archetype subclasses in Plone they should really use something like that approach instead. It would lead to much simpler maintenance in the long run, with a looser coupling of objects and less repetition of functionality. Are there any good patterns for this in Zope 3? It would be really nice to have a standard way of doing it. Setup the interfaces and class, e.g. class IContactInfo(Interface): name=schema.TextLine() email=schema.TextLine() # etc. class ContactInfo(Persistent): implements(IContactInfo) name = FieldProperty['IContactInfo'] # etc, class IContactable(Interface): Marker interface for objects which can have IContactInfo Setup an adapter from IContactable to IContactInfo. The ContactInfo object is stored as an attribute annotation on the IContactable object. def contactInfoAnnotation(ob): annotations = IAnnotations(ob) info = annotations.get('contact_info') if info is None: annotations['contact_info'] = info = ContactInfo() return info provideAdapter(contactInfoAnnotation, [IContactable], IContactInfo) Now *any object* which implements IContactable (and IAttributeAnnotatable) can have ContactInfo. You access the ContactInfo, e.g. info = IContactInfo(ob) info.name, info.email = u'My Name', u'[EMAIL PROTECTED]' # etc. For example, you could even make a file object contactable,... classImplements(File, IAttributeAnnotatable) classImplements(File, IContactInfo) ob = File() contact_info = IContactInfo(ob) You'd more likely use ZCML class implements directives to mark which content classes you want to be IContactable. It would also be nice if those objects did not show up in the navigation like folder contents. It confuses the users that they cannot delete it. But rather outside the normal navigation. Like in a portlet or as a list of actions. The attribute annotation is not publishable. You expose it explicitly via views. You can even combine it with the IContactable object in the view... class MyView(BrowserView): __used_for__=IMyObject def __init__(self, context, request): super(MyView ... self.contact_info = IContactInfo(context) # or maybe it should be IContactable(IContactInfo(context)) ? From your zpt.. span tal:replace=context/some_attr /span span tal:replace=view/contact_info/name My Name /span It's even simpler in a formlib view, because it will automatically adapt your context attribute similar to the above... class MyForm(form.DisplayForm): form_fields=form.Field( IMyObject, IContactInfo, ) In Plone that is possible by adding a dot to the id like '.contact_info', but that is a hack. Also there is no reason to have those ugly urls. Any pointers, or am I the only one thinking along those lines? Have a look at Zope3 DublinCore which is done via annotations. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: how to make static pages
Lorenzo Gil Sanchez wrote: Hi, I'd like to ask what's the best way to create static html pages inside my application. For example, the intro page, a help page or a legal conditions page. I have a skin inside a browser package but if I understand them correctly the provide views for content objects. Do I need to create a content object for the each of my static pages? No, unless you want the static page(s) to show up in results from a catalog (text) search, then Yes. Can I create a template with just the information (e.g. a view without a content)? Yes ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with SetIndex (from zc.catalog)
Thierry FLORAC wrote: Should I build any specific SetIndex subclass ? Or define a specific template ?? When I last used SetIndex from zc.catalog.index it didn't quite match the interface(s) required zope.app.catalog. It was simple enough to patch - which I can send you if you like. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with SetIndex (from zc.catalog)
Gary Poster wrote: On Mar 20, 2006, at 5:34 PM, Tom Dossis wrote: Thierry FLORAC wrote: Should I build any specific SetIndex subclass ? Or define a specific template ?? When I last used SetIndex from zc.catalog.index it didn't quite match the interface(s) required zope.app.catalog. It was simple enough to patch - which I can send you if you like. Use the ones in zc.catalog.catalogindex.py instead: they do the necessary mixing-in for zope.app.catalog friendliness, without a patch. Looks like I missed it - thank you. The purpose of the patch was to convert documentCount workCount to methods for the advanced view. I'll try it out. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with SetIndex (from zc.catalog)
Tom Dossis wrote: Gary Poster wrote: Use the ones in zc.catalog.catalogindex.py instead: they do the necessary mixing-in for zope.app.catalog friendliness, without a patch. Looks like I missed it - thank you. The purpose of the patch was to convert documentCount workCount to methods for the advanced view. I'll try it out. Turns out I was using zc.catatlog.catalogindex.SetIndex and the patch was to convert the above attributes to methods. From memory they were showing up as repr's in the advanced catalog page. Maybe there was a way to achieve this via zcml? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: FW: [Zope3-Users] Generating loginForm with formlib
I want to generate a login form for the PAU session credentials plugin. The plugin expects a form that have a login and a password field. I've created a interface: class ILoginForm(Interface): For generating the login form. login = TextLine(title=uUsername, required=True) password = Password(title=uPassword, required=True) but formlib generates the two fields with name=form.login therefore the session credentials plugin is able to extract the credentials. How can I use formlib to generate a login form? Thanks, Florian Hi Florian, the simplest thing to do (or what i ended up doing) was creating a credentialsPlugin that provided similar functionality to the standard session credentials plugin, but where the standard session credentials plugin's extractCredentials method expects to pull 'login' and 'password' out of request.get(), you just pull request.get('form.login') or something similar. just return the credentials dict back out to the principal folder (or whatever authenticator you're using) authenticateCredentials method with a dict of the form {'login': credentials.getLogin(), 'password': credentials.getPassword() } where credentials is a SessionCredentials object created from your request.get('form.login') and request.get('form.password'). look at zope.app.authentication.session's design pattern for more. I reckon the following *should* work, but it doesn't: from zope.formlib import form class MyLoginForm(form.Form): prefix='' form_fields=form.Fields(ILoginForm) ... The problem is the generated form names are '.login' and '.password'. IMHO if there's no form/widget prefix, I can't see why there should be a leading '.' character. In the end I patched zope.app.form.Widget.setPrefix() to do what I expected. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Internationalization, Widgets, and Currency
David Johnson wrote: I am trying to implement a currency input using a Float widget. However, the widget is populated with a strange character, and when saving the data that strange character causes problems. I do not see a Currency widget. What is the proper internationalization technique in regards to currency and widgets? If I just use the float widget without the locale, the numbers are displayed without the trailing zeros that are standard, although it otherwise works fine. For example, US $1.20 is displayed as 1.2. You could try a customised FloatWidget (or TextWidget) to allow you to control the display and input value formats, a e.g. class CurrencyWidget(TextWidget): def _toFieldValue(self, input): try: return float(input) # convert to currency object except ValueError, v: raise ConversionError(_(Invalid currency format ..), v) def _getFormValue(self): currency = super(CurrencyWidget, self)._getFormValue() if currency: return '$0.2f' % currency # display currency ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Zope 3.30b1 error running make check
Seems like test.py may be missing from the 3.3.0b1 release? ~/Zope-3.3.0b1 make check python install.py -q build python test.py -v python: can't open file 'test.py': [Errno 2] No such file or directory make: *** [check] Error 2 Worked ok after copying test.py from the Zope-3.2.1/ release.. regards -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Zope 3.30b1 error running make check
Stephan Richter wrote: It has been removed. It should not be part of the procedure anymore. Just ignore that step. Where did you find that? I need to update the documentation and the Makefile in the top level README.txt (line 79)... Now that the software has been built, you can run the unit tests for the software to make sure that everything is working on your platform. This is an optional step, and can take a while to complete. The tests can be run using ``make`` as well:: $ make check ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Problems with ZDC upgrading to Zope 3.3.0b1
I've encountered a problem running zope 3.3.0 beta1 against a zodb created 3.2. As a consequence of moving zope.app.dublincore to zope.dublincore, it seems DC annotations on old instances break, i.e. persistent broken zope.app.dublincore.annotatableadapter.ZDCAnnotationData instance '\x00\x00\x00\x00\x00\x00\x00%' In the meantime I can work around this by dummy'ing zope.app.dublincore. Is there a migration operation I need to run? Clicking evolve: http://localhost:8080/++etc++process/@@generations.html doesn't seem to do the trick. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Non-owning references in Zope3
[EMAIL PROTECTED] wrote: Hi, I am relatively new to Zope3. I could not find anywhere an example, what is the 'right way' to make non-owning reference to another object in Zope? Every piece of zope3 docs is full of examples of containers, this makes a good tree like structure. But how to refer from one object to another in right way? Can/should I do that with Object field? One offering is zc.extrinsicreference ... http://svn.zope.org/zc.extrinsicreference/trunk/src/zc/extrinsicreference/extrinsicreference.txt I'm not aware of any zope.schema / FieldProperty stuff to do this; it would be pretty useful though. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Two content objects' simultaneous adding
Ron Bickers wrote: On Sat May 20 2006 17:09, Ron Bickers wrote: I have two content objects (both are containers) but I cannot add one to another as give here : def create(self, data): square = Square() square.name = data['name'] square.description = data['description'] company = Company() company.name = data['companyname'] company.description = data['companydescription'] square['Comp1'] = company ... return square I did this very thing a couple days ago in 3.3 and it works for me, except that I'm using zope.app.zapi.createObject to create the instances of my content objects. Ok. So now I'm wondering... what's the point in using createObject if I can just create an object the Python way? I guess createObject could be useful in an example such as a generic add-objects menu. In this scenario it's probably be easier to deal with factory names. Otherwise I can't see why you shouldn't do it the python way if it's more direct/explicit. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling PageTemplate in Content object
David Johnson wrote: I'm trying to call a page template in a content object, but nothing seems to happen. No exceptions, no output, and no errors. I figure I'm missing something. Anyone have ideas? ... from zope.pagetemplate.pagetemplatefile import PageTemplateFile class OrderView: def city(self): return 'Fort Worth' class ProcessStep(StepFactory): implements(IProcessStep) orderform = PageTemplateFile('orderform.pt') def message(self,request): return self.orderform(self,order=OrderView()) ... orderform.pt ... html body My City Is: div tal:replace=order/city/ /body /html ... step.message(request) *** Note how nothing is returned - no exceptions and no output. Have a look at zope/pagetemplate/readme.txt - it shows (one way) how to inject 'order' into the tal 'namespace'., e.g. class MyPageTemplateFile(PageTemplateFile): ... def pt_getContext(self, args=(), options={}, **kw): ... rval = PageTemplateFile.pt_getContext(self, args=args) ... options.update(rval) ... return options orderform=MyPageTemplateFile('orderform.pt') orderform(order=OrderView()) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] New annotations factory problems
Ron Bickers wrote: On Wed May 24 2006 16:42, Tom Dossis wrote: I haven't been following this thread, however from the error message it appears your adapter is missing the context (adaptee)... def __init__(self, context): # context is the IItem object to be adapted. The README says the following: Note that the annotation implementation does not expect any arguments to its `__init__`. Otherwise it's basically an adapter. And the example is defined as follows: class Bar(Persistent): interface.implements(IBar) component.adapts(IFoo) def __init__(self): self.a = 1 self.b = 2 That's why I didn't think the adapter directive would do the right thing, but all of this (Zope 3) is pretty new to me, so what do I know. Mmm, I hadn't seen this before. from zope.annotation import factory component.provideAdapter(factory(Bar)) Did you try something like... ? MyFactory=factory(ItemMiscInfo) And corresponding zcml.. adapter factory=.mymodule.MyFactory ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling PageTemplate in Content object
[EMAIL PROTECTED] wrote: * The default namespace for *custom* keyword agruments is called *options* in a page templates. * That's a useful summary I didn't pickup. Thank you ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling PageTemplate in Content object
David Johnson wrote: I still wonder why calling PageTemplate does not always render output or not give errors. That's the strangest part. At least with errors the problem would be diagnosible. Sounds like the error (exception) is being swallowed up somewhere - or perhaps the code isn't running as you expect. I got an error when I tried it directly in the zopectl debug interpreter (and likewise - output when it ran properly). I will try the options/ format to see if I have any success. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MultiCheckBoxWidget and formlib
Mats Nordgren wrote: Could anyone give me a hint on setting up a MultiCheckBoxWidget with formlib? This is what I got: class IMySchema(Interface): multichoice = Set( title=_('Pick one or many'), value_type = Choice(values=['one', 'two', 'three'])) class MyEditForm(form.EditForm): form_fields = form.Fields(IMySchema) form_fields['multichoice'].custom_widget = What in the world do I do to get this to work? I've done something similar along the lines of... class IMySchema(Interface): multichoice = Set( title=_('Pick one or many'), value_type=SimpleVocabulary.fromItems([ (_(One), one), (_(Two), two), (_(Three, three), ]) Maybe try zope.app.form.browser.MultiSelectWidget .. It requires 3 args in its constructor which you can wrap for formlib, e.g. class MyMultiSelectWidget(MultiSelectWidget): def __init__(self, field, request): super(MyMultiSelectWidget, self).__init__( field, field.value_type.vocabulary, request) Then .. form_fields['multichoice'].custom_widget=MyMultiSelectWidget You could also look at the alternative widget.. zope.app.form.browser.itemswidgets.MultiCheckBoxWidget ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Custom index implementation
Achim Domma wrote: Hi, I try to implement a custom index to be inserted into a catalog. I look at the code and it seems to me, that I only have to derive my interface from ICatalogIndex. I have defined my interface like this: class ITestIndex(zope.app.catalog.interfaces.ICatalogIndex): pass Then I have implemented a class which implements this interface and have it registerd like this: class class=.Workspace.TestIndex require permission=zope.ManageServices interface=.interfaces.ITestIndex zope.index.interfaces.IStatistics set_schema=.interfaces.ITestIndex / /class If I restart zope and go to my catalog, I still can only add FieldIndex and TestIndex. What else do I have to do, to implement a custom index? You need to specify an addMenuItem directive and associated view in your package browser zcml to enable you to add your index objects via the ZMI. Look at zope/app/catalog/browser/configure.zcml as a starting point, e.g. addform name=AddTestIndex label=Add a test index schema=..interfaces.ITestIndex permission=zope.ManageServices content_factory=..WorkSpace.TestIndex arguments=field_name keyword_arguments=interface field_callable / addMenuItem title=Test Index description=My Test Index class=..Workspace.TestIndex permission=zope.ManageServices view=AddTestIndex / ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?
Michael Dexter wrote: My question is thus very naive: what is the ++xyz++ and @@xyz syntax and can it be avoided? yes... The following are normally all equivalent.. http://host/content/++view++edit.html http://host/content/@@edit.html http://host/content/edit.html This presumes that you've configured (normally via zcml) a (Browser)View class named 'edit.html'. If in a particular circumstance, 'content' is a container object which contains an object with the name (id) 'edit.html', then you can explicitly distinguish between this object and the named view 'edit.html' using the 'view' namespace. Look at the inline doc. in zope/traversal/namespace.py for more info about the (very useful) 'namespace' traversal in zope3. Skin variables in URL would be great during development but suggest that the user can make skin selection. I guess the user can make their own skin selection via the url. This presumes the user has permission to access that skin. To disable the url selection of the skin I 'guess' you'd need to override (knock out) the ++skin++ namespace traversal (sorry I can't help you with this one). Keep in mind I have no idea if ++thisskin++ is required as I cannot find the aforementioned explanation of that syntax. If @@ is for inspection, is this something the public can/should do? Security issues? The introspector.html view (adapter) isn't configured with public access. Also you'll find the url/@@introspector.html and url/introspector.html normally both work as described above. If my Zope2 site uses http://worldcookery.com/About and my Zope3 site uses http://worldcookery.com/++kewlskin++About then the existing links are presumably dead or inaccurate. In practice you would specify your desired skin (to override) in your $INSTANCE/etc/overrides.zcml file. Or you could even wire in the ++skin++ into your (apache) rewrite rules. Happy to once I get it but alas, I still don't. I do sincerely appreciate Zope's overall use of precise terminology but that terminology must be spelled out very carefully in layman's terms if you are to not frustrate the uninitiated. You can always try this mail list if the books and/or zope3 doco. isn't helping... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Getting started with testbrowser
Darryl Cousins wrote: from zope.testbrowser import Browser browser = Browser() browser.addHeader('Authorization', 'Basic mgr:mgrpw') oops: browser = Browser('http://localhost/contents.html') # should be browser.open('http://localhost/contents.html') ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permissions for updateOrder() on OrderedContainer
Arne Nordmann wrote: A.updateOrder(['C', 'B']) Traceback (most recent call last): ... ForbiddenAttribute: ('updateOrder', mypackage.cont.Cont object at 0x022244B0 - (object at 0x022244B0 is OrderedContainer 'A') configure.zcml defines each used interface with permission 'ManageContent' and I'm logged in as 'Manager'. Accessing the method keys(), values(), etc. of the OrderedContainers is no problem. So what's the problem? Hi, just confirming that you've included a directive for IOrderedContainer, e.g. class class=mypackage.cont.Cont ... require permission=zope.ManageContent interface=zope.app.container.interfaces.IOrderedContainer / ... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] What kind of Zope3 classes are available?
Steve Juranich wrote: Can anybody clue me in on what classes might be available for me to get a little better acquainted with Zope3? http://lovelysystems.com/training/lovely-zope-3-training-copenhagen I have the Zope 3 Developer's Handbook, and it's servicable, but I'm afraid I'm much more of an auditory learner. There's also 'Web Component Development with Zope3 - http://worldcookery.com/About . It offers a different slant to the Developers Handbook. Some parts of it are now out of date wrt Zope 3.3. There are also some tutorials on worldcookery.com. Regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Performance
David Johnson wrote: Okay. I think I figured it out. It seems that images and large objects are the main culprit. We have very few images, mainly just icons for the content types and tabs. I discovered this by using lynx and with IE disabling images. So the new question is: how do I speed up image downloading? I'm guessing this has something to do with the ZODB? Hi David, Here's some 'benchmarks' for you to compare against. I accessed images both as resources and content objects. Though there was some difference b/w them it wasn't by any order of magnitude I used a recent Zope3 version from svn.zope.org. From the results it looks like data bandwidth may be a factor to consider. Also my benchmark client is written in python using twisted and it also adds it's own (significant) overhead. I also ran some tests against Zope instances and ZEO (results not included), which didn't turn up any weird result. object=neptune.jpg size=3.39MB 1/ Accessed as resource, content is served from the file system.. Requests:20 Errors: 0 Async level: 8 kBytes rcvd: 71097.0 Total time: 4.08 sec Req rate:4.9 req/sec Data rate: 17416.7 kB/sec Get ave: 0.204 sec #Req #Err Get(ave) (min) (max)kB/s URL 20 0 1.458 0.855 1.695 2438.4 http://localhost:8082/@@/neptune.jpg 2/ Accessed as a Image content (ZODB) object with a Zope/ZODB instance.. Requests:20 Errors: 0 Async level: 8 kBytes rcvd: 71097.0 Total time: 4.09 sec Req rate:4.9 req/sec Data rate: 17397.5 kB/sec Get ave: 0.204 sec #Req #Err Get(ave) (min) (max)kB/s URL 20 0 1.462 0.867 1.685 2431.2 http://localhost:8082/content/neptune.jpg object=sts.jpg size=371kB 3/ Smaller image accessed as resource object Requests:100 Errors: 0 Async level: 8 kBytes rcvd: 37996.2 Total time: 1.08 sec Req rate:92.8 req/sec Data rate: 35274.5 kB/sec Get ave: 0.011 sec #Req #Err Get(ave) (min) (max)kB/s URL 100 0 0.085 0.035 0.109 4456.0 http://localhost:8082/@@/sts.jpg 4/ Smaller image accessed as content object Requests:100 Errors: 0 Async level: 8 kBytes rcvd: 37996.2 Total time: 1.41 sec Req rate:70.7 req/sec Data rate: 26870.1 kB/sec Get ave: 0.014 sec #Req #Err Get(ave) (min) (max)kB/s URL 100 0 0.112 0.042 0.156 3381.7 http://localhost:8082/content/sts.jpg ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] help ! Zope 3.2.1 won't start any longer !
catonano wrote: Microsoft Windows XP [Versione 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\adrianod: D:\ZopeIstanza\bin\runzope Error: 'formatter' is not a known key name (line 103 in file:/D|/ZopeIstanza/etc/zope.conf) For help, use D:\ZopeIstanza\bin\runzope -h Try commenting out the problem line(s) in your zope.conf, e.g. logfile path $LOGDIR/z3.log # formatter zope.exceptions.log.Formatter /logfile logfile path STDOUT # formatter zope.exceptions.log.Formatter /logfile In my zope 3.2 instance, the zope.conf file doesn't contain the formatter params. (but my 3.3 version does). ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Zope 3.3.0 - Adding Utilities to Content Space
Philipp von Weitershausen wrote: On behalf of the Zope 3 development team I'm proud to announce the final Zope 3.3.0 release. There were no changes since the 3.3.0 release candidate. I've noticed the following changes in the zope 3.3 ZMI Zope 3.3 - Can add utilities anywhere, e.g. to Folders (content space). Zope 3.2 - Can only add utilities to a Site Mgmt Folder Zope 3.3 - All Objects have a ZMI Registration Tab Zope 3.2 - Only ILocalUtility? objects have a reg. tab Is this intentional? I seem to recall an objective of zope3 was to remove 'tools' from content space? Thanks -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Looking for best practice in content indexing
Thierry Florac wrote: - generally speaking, is it better to keep a single big catalog, or a set of many catalogs, each of them indexing a smaller set of classes ? I suppose that querying is more simple with a single catalog, but what about general performances ?? With the hurry.query package it's just as easy to query across multiple (named) catalogs. I prefer to avoid monolithic catalogs with lots of indexes. - I have to index main content, but also reference classes which are used to classify my main content (example : I describe forests in a first step and afterwards, my main contents can be affected to one or more forests). In such a case, I want to make queries concerning forests themselves, but also queries about main content concerning forests they are attached to (to get, for example, every subject attached to a given forest). In this case also, is it better to keep track of the reference itself (myContent.forest = myForest) or of an attribute of the reference (myContent.forestId = myForest.uniqueId) ?? - perhaps a stupid question, but what's the best method to get the equivalent of Zope2's meta_type indexing, to only get instances of a given class, when queried indexes are applied to several classes (example : I use adapters to handle workflow publication on a wide set of classes, and I want to retrieve contents of a given class in a given workflow step) ?? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] ReadOnly svn access not working
I'm aware there are some current issues with www.zope.org. but just in case this has been missed... svn ls svn://svn.zope.org/repos/main svn: Can't connect to host 'svn.zope.org': Connection refused Thanks -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Nested lists- iteration over non-sequence
Daniel M wrote: Hi Kevin, Thanks for the help! I've studied your example at http://zope3demos.googlecode.com/svn/tags/zope3demos-200610-21/otherdemos/objectsofobjects2/ but I don't see how I could extend this example into a List of List. Suppose I want to change your IPerson to include a list, such as: class IPerson(interface.Interface): first = schema.TextLine(title=ufirstname) last = schema.TextLine(title=ulastname) names = schema.List(title=u'Names', value_type=schema.TextLine(title=unames), required=False) I can't figure out how to create to modify the widgets so that AddressBook will display correctly... I keep getting the Iteration over non sequence exception. Hi Daniel, Taking the error at face-value, the following may (or not) help: names = schema.List(title=u'Names', value_type=schema.TextLine(title=unames), required=False, default=[]) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] how to access the root folder in normal operation
Hi Shailesh, have a look at zope.traversing.api. There's a getRoot-method. Cheers -Tom Shailesh Kumar wrote: Hi, In a functional test setup, one can access the root folder using getRootFolder() of FunctionalTestSetup. How can I access the root folder in a nomal operation mode? Is there some mechanism to do that? Thank you very much. With regards, -shailesh ___ 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] suppressing menu item
Sascha Ottolski wrote: Hi, I created a sub-interface of IFile, say IMyFile(IFile), which has it's own Edit form, configured like this: editform for=..IMyFile schema=..IMyFile class=.EditMyFile permission=zope.ManageContent name=editmyfile.html menu=zmi_views title=Edit / Now that everything works, I want to switch off the Upload Tab that is configured for IFile, and therefore inherited by IMyFile as well: browser:page name=upload.html menu=zmi_views title=Upload for=zope.app.file.interfaces.IFile template=file_upload.pt class=.file.FileUpload permission=zope.ManageContent / Is it possible, and if, how? Hi Sascha, I think if you name your page (editform) 'upload.html' rather than 'editmyfile.html' it will effectively override the base view. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] question about MailDir folder for queuedDelivery on windows
Hi Shailesh, just make sure there are three subdirectories available in the directory of your mailqueue: cur, tmp, new. This is the common maildir format. see: man 5 maildir *THE* *MAILDIR* *STRUCTURE* A directory in /maildir/ format has three subdirectories, all on the same filesystem: *tmp*, *new*, and *cur*. Each file in *new* is a newly delivered mail message. The modification time of the file is the delivery date of the message. The message is delivered /without/ an extra UUCP- style *From_* line, /without/ any *From* quoting, and /without/ an extra blank line at the end. The message is normally in RFC 822 format, starting with a *Return-Path* line and a *Delivered-To* line, but it could contain arbitrary binary data. It might not even end with a newline. Files in *cur* are just like files in *new*. The big difference is that files in *cur* are no longer new mail: they have been seen by the user's mail-reading program. Cheers -Tom Shailesh Kumar wrote: Hi, I am trying to use mail:queuedDelivery. It says that the /...\lib\python\baton\mail_queue is not a Maildir folder/ I am using Zope on Windows-XP box. How can I setup a Maildir folder? With regards, -shailesh ___ 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] how to access the root folder in normal operation
Hi Shailesh, take a look at zope.app.appsetup. You could subscribe to the DatabaseOpenedWithRoot-event. Cheers -Tom Shailesh Kumar wrote: Hi, zope.traversing.api.getRoot returns the root of a given object. What I wanted to do was that when zope starts, I would like to create a few content objects inside the root folder. Something like: root = getRootFolder() #using some way I don't know. root['etc'] = Folder() root['var'] = Folder() ... Is it possible to do that? With regards, -shailesh On 11/15/06, *Tom Gross* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Shailesh, have a look at zope.traversing.api. There's a getRoot-method. Cheers -Tom Shailesh Kumar wrote: Hi, In a functional test setup, one can access the root folder using getRootFolder() of FunctionalTestSetup. How can I access the root folder in a nomal operation mode? Is there some mechanism to do that? Thank you very much. With regards, -shailesh ___ Zope3-users mailing list Zope3-users@zope.org mailto: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] Custom Content Container
Hi David, which fields does your IOwner-interface consist of? You get this error if you call an auto generated form from a List-field, without having value_type specified, but there are other scenarios, so this information would be helpful. Cheers -Tom David Johnson wrote: I created a custom content container that reads entries from a MySQL database and allows editing of the container objects. Or at least that is my desire... The content container by itself “seems” to work well. However when I click on an object in the contents ZMI view, I receive the following exception: ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0x420f450c, zope.publisher.browser.BrowserRequest instance URL=http://192.168.81.89:8070/++etc++site/default/TPM%20on%20Dev/4/@@editTPMOwner.html), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') I’m not quite sure why “IInputWidget” is being looked up, though I suppose it has something to do with the form I am creating, and I’m not sure why it is not finding what it is looking for. editTPMOwner.html is simply a browser:editform ZCML directive that uses schema IOwner. Any ideas or thoughts? Thanks so kindly in advance. -- David Johnson ___ 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] how to know which port zope is runnning on?
Hi Shailesh, try request.get('SERVER_PORT'). Cheers -Tom Shailesh Kumar wrote: Hi, Is it possible for the application code to figure out the port number on which zope is running? What is the suitable api for that? With regards, -shailesh ___ 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] Custom Content Container
Hi David, I found another workaround. I defined a dummy Widget for the abstract Field-field. Something like this: from zope.app.form.browser.widget import SimpleInputWidget class DummyWidget(SimpleInputWidget): def __call__(self): pass and additional in zcml: view type=zope.publisher.interfaces.browser.IBrowserRequest for=zope.schema.interfaces.IField provides=zope.app.form.interfaces.IInputWidget factory=.DummyWidget permission=zope.Public / Although it's a workaround it looks a bit nicer in the code :). You can use container constraints the intended way. Cheers -Tom David Johnson wrote: I figured out the problem. In my interfaces I was using the contains and containers methods. When I stuck to the more tedious __parent__ = ... approach as outlined in Stephan's book, all was solved. Thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Johnson Sent: Tuesday, November 28, 2006 2:21 PM To: 'Tom Gross' Cc: zope3-users@zope.org Subject: RE: [Zope3-Users] Custom Content Container Yes indeed. I'm only using 1 Text and 3 TextLine fields. This is my first attempt at this so I'm trying to keep it fairly simple. -Original Message- From: Tom Gross [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 28, 2006 2:05 PM To: David Johnson Cc: zope3-users@zope.org Subject: Re: [Zope3-Users] Custom Content Container Hi David, which fields does your IOwner-interface consist of? You get this error if you call an auto generated form from a List-field, without having value_type specified, but there are other scenarios, so this information would be helpful. Cheers -Tom David Johnson wrote: I created a custom content container that reads entries from a MySQL database and allows editing of the container objects. Or at least that is my desire... The content container by itself seems to work well. However when I click on an object in the contents ZMI view, I receive the following exception: ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0x420f450c, zope.publisher.browser.BrowserRequest instance URL=http://192.168.81.89:8070/++etc++site/default/TPM%20on%20Dev/4/@@editT PMOwner.html), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') I'm not quite sure why IInputWidget is being looked up, though I suppose it has something to do with the form I am creating, and I'm not sure why it is not finding what it is looking for. editTPMOwner.html is simply a browser:editform ZCML directive that uses schema IOwner. Any ideas or thoughts? Thanks so kindly in advance. -- David Johnson -- -- ___ 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 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] schema field for an Image?
Sascha Ottolski wrote: I'm wondering if anything already exists, that would allow me to define a schema like (pseudo) IPerson(Interface): image = File( max_size=100, ) Person(Persistent): implements(IPerson) image = FileProperty(form_fields['image']) with the result, that the image attribute behaves pretty much like an IImage, that is, has contentType and size associated with it, and might be easily displayed with the help of something like zope.app.file.browser.image.ImageData. I already tried to create such a Property, as well as using schema.Object, but wasn't really successfull :-( Hi Sacha, I've used something like this... class IPerson(Interface): image=schema.Object( schema=zope.app.file.interfaces.IImage, required=False, # You may need this depending on validation needs.. ) class Person(Persistent): implements(IPerson) image=FieldProperty(IPerson['image']) If you want to make the image attribute traversable (via the url) the z3c.traverser package can do the job. Of course, I can do all this by hand for each content object by adding a contentType attribute and providing some views, but I have the feeling that there would exist a smarter way to to this. Adding to this, is there a way to register views with fuzzy names? Think of a class Person: resume = File() Now, to help the logfile analyzer, I would like to have a view named resume.%s', so that if resume is a Word document, it could be accesed as /person1/resume.doc, if resume is PDF, access would be /person1/resume.pdf. I could register several views for common suffixes, but than there comes a buy with one no one thought of. May be this is a stupid idea anyway :-) Have a look at zope.publisher.interfaces.IPublishTraverse to hook in your own handler for traversing a Person object. regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
FB wrote: Hi, is there any reason why a registered utility which is persistently stored inside the site manager is never found via zapi.getUtility(IMyInterface) ? More information: I wrote a package ( fb ) containing some components making the developer's life easier. The package provides a class fb.init.indicator.InitIndicator. A application depending on the fb package is supposed to make an instance of the InitIndicator, put it into the site manager and register it. As soon as the InitIndicator exists, the annoying This site is not initialized, yet-message provided by the fb package's skin (which just checks if zapi.getUtility(IInitIndicator) is not None) disappears. But: It *doesn't work* and a don't have the slightest clue why. This is, what my application's initialisation routine does: def initApplication(root): sm=getSiteManager() df=sm['default'] initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',uno info) df['initindicator']=initindicator sm.registerUtility(df['initindicator'],IInitIndicator,'','') [...] test=zapi.getUtility(IInitIndicator) # Works! [...] Querying the IInitIndicator component works directly after the registration but *nowhere* else in my application. Have you 'browsed' the utility via the ZMI 'Manage Site'? Is there an instance there (in the site you expect it to be)? If so the 'Registration' page could provide some useful info. Regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Custom Image Widget
Adam Summers wrote: Hi, I have the following widgets. class MyImageDisplayWidget(DisplayWidget): class_ = Image def __call__(self): mycontent = uoops! no img if self._renderedValueSet(): mycontent = img src=\data:image/gif;base64, + b64encode(self._data.data) + \ / return mycontent MyImageListDisplayWidget = CustomWidgetFactory(SequenceDisplayWidget, subwidget = MyImageDisplayWidget) class MyImageWidget(FileWidget): class_ = Image def _toFieldValue(self, input): value = super(MyImageWidget, self)._toFieldValue(input) return self.class_(value) MyImageListWidget = CustomWidgetFactory(ListSequenceWidget, subwidget = MyImageWidget) I want to build a better input widget (MyImageWidget), so that we can do the following: * If the field has no data, display a file input. * If the field has data, display the image. I know that there are design shortcomings in this, but I need a simple example (and I only use the files in lists anyway, so I can delete images). Any pointers on how to go about this would be much appreciated; as always Hi Adam, I'm not exactly sure of your use case, but I've included a widget implementation (see below) which you may find useful. I've used this widget for an attribute which is an IImage, e.g. class IContent(zope.interface.Interface): image=zope.schema.Object(schema=zope.app.file.interfaces.IImage) class Content(persistent.Persistent): # This property makes the image object locatable (see below) image=LocatableProperty(IContent['image']) ImageAttributeTraverser=\ z3c.traverser.traverser.SingleAttributeTraverserPlugin('image') ## property.py from zope import location from zope.schema.fieldproperty import FieldProperty def LocatableProperty(field_or_descriptor): A property which ensures a field instance is locatable. The argument can be a field or a descriptor for that field. The zope.fieldproperty.FieldProperty descriptor is used internally when a field object argument is passed. A locatable property can be used for traversable attribute objects to locate them in the referencing object. Let's create a simple content object with an attribute which is an image: from zope import schema from zope.app.file.interfaces import IImage image_field=schema.Object(__name__='image', schema=IImage) class Content(object): ... image=LocatableProperty(image_field) ob = Content() ob.image is None True Assign an image object which doesn't have location to the attribute: from zope.app.file import Image image = Image(data='1234') image.__parent__ Traceback (most recent call last): ... AttributeError: 'Image' object has no attribute '__parent__' ob.image = image When we now access the attribute object, it we find that is has been wrapped inside a location proxy object: ob.image.__parent__ is ob True ob.image.__name__ 'image' ob.image.data '1234' try: field_or_descriptor.__get__ field_or_descriptor.__set__ return Locatable(field_or_descriptor) except AttributeError: return Locatable(FieldProperty(field_or_descriptor)) class Locatable(object): Wrap a FieldProperty descriptor to make it's field locatable. def __init__(self, descriptor): self.descriptor = descriptor self.name = self.descriptor._FieldProperty__name def __get__(self, inst, cls): ob = self.descriptor.__get__(inst, cls) if ob is not None: if location.interfaces.ILocation(ob, None) is None: ob = location.LocationProxy(ob, inst, self.name) return ob def __set__(self, inst, ob): self.descriptor.__set__(inst, ob) ## widget.py from zope.event import notify from zope.lifecycleevent import ObjectCreatedEvent from zope.i18n import translate from zope.dublincore.interfaces import IZopeDublinCore from zope.size.interfaces import ISized from zope.component import getMultiAdapter from zope.traversing.browser import absoluteURL from zope.app.file import Image from zope.app.file.browser.image import ImageData from zope.app.form.browser import DisplayWidget from zope.app.form.browser import FileWidget class ImageDisplayWidget(DisplayWidget): def __call__(self): field = self.context image = field.get(field.context) if image is None: return u(No image object) alt = IZopeDublinCore(image).title or '' title = IZopeDublinCore(image).description or '' v = ImageData() v.context, v.request = image, self.request return v.tag(alt=alt, title=title) class ImageInputWidget(FileWidget): def _toFieldValue(self, input): data = super(ImageWidget,
Re: [Zope3-Users] Registered utility is never found
Hi Frank, is your InitIndicator-instance implementing the IInitIndicatorFB-interface. This is absolutely necessary for providing it as an utility. There's an easy test for this: from zope.interface.verify import verifyObject ii = InitIndicator() verifyObject(IInitIndicatorFB, ii) True I usually put this in the docstring of classes I want to use as utilities. Just to make sure :-). -Tom wrote: Hi, On Tue, Dec 12, 2006 at 07:56:53AM +1100, Tom Dossis wrote: FB wrote: Hi, is there any reason why a registered utility which is persistently stored inside the site manager is never found via zapi.getUtility(IMyInterface) ? More information: I wrote a package ( fb ) containing some components making the developer's life easier. The package provides a class fb.init.indicator.InitIndicator. A application depending on the fb package is supposed to make an instance of the InitIndicator, put it into the site manager and register it. As soon as the InitIndicator exists, the annoying This site is not initialized, yet-message provided by the fb package's skin (which just checks if zapi.getUtility(IInitIndicator) is not None) disappears. But: It *doesn't work* and a don't have the slightest clue why. This is, what my application's initialisation routine does: def initApplication(root): sm=getSiteManager() df=sm['default'] initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',uno info) df['initindicator']=initindicator sm.registerUtility(df['initindicator'],IInitIndicator,'','') [...] test=zapi.getUtility(IInitIndicator) # Works! [...] Querying the IInitIndicator component works directly after the registration but *nowhere* else in my application. Have you 'browsed' the utility via the ZMI 'Manage Site'? Is there an instance there (in the site you expect it to be)? If so the 'Registration' page could provide some useful info. Yes. The instance is there, the registration tab shows the registration as expected, the site root folder itself lists the registration in site.registrations lists the registration as expected. Registering via browser doesn't work either :-( . BTW: I've got dozens of other utilities registered that are working perfectly. Frank ___ 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] Registered utility is never found
Hi Frank, you are trying to lookup the utility with the name None. If you don't specify a name when registering the utility, omit the second parameter: zapi.getUtility(IInitIndicator) Cheers -Tom FB wrote: On Tue, Dec 12, 2006 at 05:29:55PM +0300, Garanin Michael wrote: FB wrote: On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote: traceback, please. Hmm ... how? It just doesn't return the utility as expected (it returns None). There is no error shown in any way. from APIDOC: * *|getUtility(interface, name='', context=None)| * . If one is not found, raises ComponentLookupError. must be EXCEPTION !!! There are not ComponenLookupError exception? Why you find bug in getUtility? ;-) Sorry - my fault :-) I'm using queryUtility all the time. Here's the traceback: File /var/lib/zope3/instance/lib/python/fb/init/tales.py, line 29, in warn indicator=zapi.getUtility(IInitIndicator,None) File /ZOPE/zope3/src/zope/component/_api.py, line 207, in getUtility raise ComponentLookupError(interface, name) ComponentLookupError: (InterfaceClass fb.init.interfaces.IInitIndicator, None) Regards, Frank ___ 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] Custom Image Widget
Adam Summers wrote: Hi Tom Widget Afficionados. Thanks for the help so far. My problem is now this: From this code (which Tom supplied), how do I code the logic (in bold) def _toFieldValue(self, input): data = super(ImageWidget, self)._toFieldValue(input) if data is not None: img = Image(data) notify(ObjectCreatedEvent(img)) return img *else: #data is None, ie. the File input field was left blank and we don't want to #replace the current value of the Image Widget with an empty value. currentImg = the Image object which the field is being rendered for return currentImg * I can't rely on field = self.context image = field.get(field.context) logic to find the data, because my schema can contain: class Iclaim(IContained): Claim supDoc = List(title=_(uSupporting Docs List), value_type=Object(IImage, __name__='ImgItem', title=_(uImage))) img = Object(IImage, title=_(uSingle img), required=False) And hence, the self.context.context points to the claim object, not the list inside when rendering supDoc Hi Adam, You can rely on: field = self.context image = field.get(field.context) because the widget is for an attribute object of type IImage. Your supDoc attribute object is a List Type - not an IImage. In this case you'd need another widget - for a list of IImage. I wouldn't been too keen to tackle the html work effort and would probably look at an alternative along the lines of... class IImageList(IContainer): contains(zope.app.image.interfaces.IImage) class IClaim(IContained): supDoc=Object(schema=IImageList) Make supDoc traversable, then you wouldn't need the custom widget here because you can store Images directly in supDoc view with the browser:containerView's. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] readline() takes exactly 1 argument
George Wright wrote: Apply this patch to the zope3-sources: /http.py --- src/zope/publisher/http.py.old 2006-10-04 15:11:04.0 +0200 +++ src/zope/publisher/http.py 2006-10-04 15:11:04.0 +0200 @@ -205,7 +205,7 @@ return data def readline(self,size=None): -data = self.stream.readline(size) +data = self.stream.readline() self.cacheStream.write(data) return data BUT I'm not sure what to do with it! What do the little - and + in front of the data = lines mean? And the @@ -205,7 +205,7 @@ ? Remove the '-' line, replace it with the '+' line. Just which http.py is to be patched? ~/Zope-3.3.0/build/lib.macosx-10.3-fat-2.4/zope/publisher/http.py OR ~/Zope-3.3.0/build/lib.darwin-8.8.0-Power_Macintosh-2.4/zope/publisher/http.py OR ? Both if need be - but definitely in your runtime path. Should I be able to call zope from within terminal? I can get interface ( probably because it is part of my twisted installation which is OK) But I can't get other zope stuff. cd to your zope INSTANCE_HOME, then you can invoke the python interpreter with either of: ./bin/zopectl debug or ./bin/debugzope This will add zope (and $INSTANCE_HOME/lib/python) to your python path and process all the zcml files. It will also add 'app' to your python session... app zope.app.debug.debug.Debugger object at 0xb741010c app.root() zope.app.folder.folder.Folder object at 0xb4fe706c list(app.root()) [u'Folder1', u'Folder2'] from zope import schema dir(schema) ['ASCII', 'ASCIILine', 'Bool', 'Bytes', 'BytesLine', 'Choice', 'Container', 'Date', 'Datetime', 'Dict', 'DottedName', 'Field', 'Float', 'FrozenSet', 'Id', 'Int', 'InterfaceField', 'Iterable', 'List', 'MinMaxLen', 'Object', 'Orderable', 'Password', 'Set', 'SourceText', 'Text', 'TextLine', 'Timedelta', 'Tuple', 'URI', 'ValidationError', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '_bootstrapfields', '_bootstrapinterfaces', '_field', '_schema', 'accessors', 'fieldproperty', 'getFieldNames', 'getFieldNamesInOrder', 'getFields', 'getFieldsInOrder', 'interfaces', 'vocabulary'] ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] getUtilitiesFor without context
Florian Lindner wrote: Hello, I have some local utilites registered. Now I try to call them from a function that don't have a context: utils = getUtilitiesFor(INewsfeed) for i in utils: print Utility called:, i.__name__ i.sendNotification() but that always deliver no utilities. How do get them without supplying a context. (the function is called regularly from a scheduler object, therefore it needs to be static) I'm not sure what a 'scheduler object' is, but it sounds like you don't have you don't have a current site. You can confirm this with: from zope.app.component import hooks print hooks.getSite() # None Use: # work out what your site hook.set(site) before your util lookups. regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] getUtilitiesFor without context
Florian Lindner wrote: Use: # work out what your site hook.set(site) Mhh, the hook object does not exist, hooks does not have a attribute set. What object do you refer to? My apologies, should be: hooks.set(site) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] getUtilitiesFor without context
Tom Dossis wrote: Florian Lindner wrote: Use: # work out what your site hook.set(site) Mhh, the hook object does not exist, hooks does not have a attribute set. What object do you refer to? My apologies, should be: hooks.set(site) hooks.setSite(site) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Customized NotFound-Page
Hi, I created a customized 'NotFound'-Page which displays fine itself. Now the page should render in a skin with some security sensitive viewlets. These viewlets disappear when rendering the 'NotFound'-Page. Is there a known solution to the problem? Thanks, Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] objectwidget help
Hi Ivan, I might be wrong, but I think there's an example for listwidgets containing objects in the zope3demos-package: http://code.google.com/p/zope3demos/ Maybe it helps. Cheers -Tom Ivan Horvath wrote: Dear All, in my implementation there is an object. one of this object properties is a List. containing other objects. the class which inherits ObjectWidget receives always the same context, actually that object which contains the object property. class MyDispFieldsWidgetDisplay(ObjectWidget): i cannot find the way how to tell to MyDispFieldsWidgetDisplay object which element should read from the List object property this is my viewclass: class DKRviewReportView(myBrowserView): - myBrowserView is almost the same as the zope BrowserView class fields_widget = CustomWidgetFactory(SequenceDisplayTableWidget, subwidget=MyDispFieldsWidgetDisplay) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] objectwidget help
Hi Ivan, did you get the code from the repository? It's: svn checkout http://zope3demos.googlecode.com/svn/trunk/ zope3demos Cheers -Tom Ivan Horvath wrote: thank you Tom! i downloaded, but unfortunately i cannot see it in my browser. what is the url for the otherdemos objectsofobject2 package? Tom Gross wrote: Hi Ivan, I might be wrong, but I think there's an example for listwidgets containing objects in the zope3demos-package: http://code.google.com/p/zope3demos/ Maybe it helps. Cheers -Tom Ivan Horvath wrote: Dear All, in my implementation there is an object. one of this object properties is a List. containing other objects. the class which inherits ObjectWidget receives always the same context, actually that object which contains the object property. class MyDispFieldsWidgetDisplay(ObjectWidget): i cannot find the way how to tell to MyDispFieldsWidgetDisplay object which element should read from the List object property this is my viewclass: class DKRviewReportView(myBrowserView): - myBrowserView is almost the same as the zope BrowserView class fields_widget = CustomWidgetFactory(SequenceDisplayTableWidget, subwidget=MyDispFieldsWidgetDisplay) -- Best Regards, Iván Horváth Chief Programmer Alcatel NSD PMS 2000 Product Team H-1116, Budapest Kondorfa u. 10. Tel.: +36 1 209 9546 Fax.: +36 1 209 9599 Mobil: +36 30 257 0235 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Check my Web Page http://www.freeweb.hu/pillesoft /Anyone who has never made a mistake has never tried anything new./ / /Albert Einstein/ / ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] objectwidget help
Hi Ivan, the demos are all together quite outdated. In your case there's a wrong url provided in the index-template it should be: a href=/@@contents.html?type_name=BrowserAdd__zope3demos.otherdemos.formlib2.demo.OrderCreate Formlib2 Demo Object/a instead of a href=/@@contents.html?type_name=BrowserAdd__zope3demos.formlib2.demo.OrderCreate Formlib2 Demo Object/a You can create the object via the 'Add:'-Navigation. Choose 'Formlib Demo Object' there. -Tom Ivan Horvath wrote: Hi Tom, yes, but i made another checkout to another folder, renamed the previous one. it is the same on the index page http://localhost:8080/@@z3d.index.html i have the following contents (below) and e.g. Create Formlib2 Demo Object http://localhost:8080/@@contents.html?type_name=BrowserAdd__zope3demos.formlib2.demo.Order link doesn't work, after entering a name to create new object gives ComponentLookupError: (InterfaceClass zope.component.interfaces.IFactory, u'Br owserAdd__zope3demos.formlib2.demo.Order') exception -- index start -- Viewlet/Contentprovider Examples * Viewlet 1 http://localhost:8080/@@z3d.demo1.index.html * Viewlet 2 http://localhost:8080/@@z3d.demo2.index.html Add content to root folder for next two demos. * Viewlet 3 http://localhost:8080/@@z3d.demo3.index.html * Viewlet 4 http://localhost:8080/@@z3d.demo4.index.html * Contentprovider 1 http://localhost:8080/@@cpdemo1.html Masterpage Examples An exploration of alternatives to macros using viewlets and content providers * Masterpages without macros 1 http://localhost:8080/@@z3d.mpdemo1.index.html * Juergen Masterpages without macros 2 http://localhost:8080/@@z3d.mpdemo2.index.html * Jurgen Masterpages stripped down o @@z3d.mpdemo3.page1.html http://localhost:8080/@@z3d.mpdemo3.page1.html o @@z3d.mpdemo3.page2.html http://localhost:8080/@@z3d.mpdemo3.page2.html * Masterpages demo4 http://localhost:8080/@@z3d.mpdemo4.index.html based on this blog posting http://blogs.lovelysystems.com/srichter/2006/09/20/the-skin-browser-and-lovely-systems-new-development-workflow/ by Stephan Richter see also viewtemplate example. Viewtemplate Example z3c.viewtemplate seperates the zpt template from the view class. * ++skin++MySkin/@@viewtemplate1.html http://localhost:8080/++skin++MySkin/@@viewtemplate1.html * ++skin++MySkin2/@@viewtemplate1.html http://localhost:8080/++skin++MySkin2/@@viewtemplate1.html Formlib Demo * /@@z3d.formlib1.page1.html http://localhost:8080/@@z3d.formlib1.page1.html * /@@z3d.formlib1.page1-length.html http://localhost:8080/@@z3d.formlib1.page1-length.html * /@@z3d.formlib1.page1-name.html http://localhost:8080/@@z3d.formlib1.page1-name.html * /@@z3d.formlib1.page2.html http://localhost:8080/@@z3d.formlib1.page2.html * /@@z3d.formlib1.page3.html http://localhost:8080/@@z3d.formlib1.page3.html * Formlib2 Demo o Create Formlib2 Demo Object http://localhost:8080/@@contents.html?type_name=BrowserAdd__zope3demos.formlib2.demo.Order o Visit the new object o Edit the new object -- index end -- Tom Gross wrote: Hi Ivan, did you get the code from the repository? It's: svn checkout http://zope3demos.googlecode.com/svn/trunk/ zope3demos Cheers -Tom Ivan Horvath wrote: thank you Tom! i downloaded, but unfortunately i cannot see it in my browser. what is the url for the otherdemos objectsofobject2 package? Tom Gross wrote: Hi Ivan, I might be wrong, but I think there's an example for listwidgets containing objects in the zope3demos-package: http://code.google.com/p/zope3demos/ Maybe it helps. Cheers -Tom Ivan Horvath wrote: Dear All, in my implementation there is an object. one of this object properties is a List. containing other objects. the class which inherits ObjectWidget receives always the same context, actually that object which contains the object property. class MyDispFieldsWidgetDisplay(ObjectWidget): i cannot find the way how to tell to MyDispFieldsWidgetDisplay object which element should read from the List object property this is my viewclass: class DKRviewReportView(myBrowserView): - myBrowserView is almost the same as the zope BrowserView class fields_widget = CustomWidgetFactory(SequenceDisplayTableWidget, subwidget=MyDispFieldsWidgetDisplay) -- Best Regards, Iván Horváth Chief Programmer Alcatel NSD PMS 2000 Product Team H-1116, Budapest Kondorfa u. 10. Tel.: +36 1 209 9546 Fax.: +36 1 209 9599 Mobil: +36 30 257 0235 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Check my Web Page http://www.freeweb.hu/pillesoft /Anyone who has never made a mistake has never tried anything new./ / /Albert Einstein/ / -- Best Regards, Iván
Re: [Zope3-Users] broken formlib - form.txt example
Vinny wrote: Using instructions from: /usr/local/www/Zope3/lib/python/zope/formlib/form.txt With code straight out of it typed into the IDLE editor, saved as form.py and run using the F5 command: Saving and running this gives: ComponentLookupError: ((zope.schema._bootstrapfields.TextLine object at 0x8cf53cc, zope.publisher.browser.TestRequest instance URL=http://127.0.0.1), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') Sigh. Am I jinxed? I've been trying to learn zope 3 for six months now. All I want is to be able to make a form from an interface and display the dang thing. Is that too much to ask? /rant Does anyone know what's going wrong? Do I need to upgrade anything? Looks like you haven't done the 'setup' to wire-in the widgets (refer to zope/formlib/tests.py which sets up the components used in form.txt). ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Error when calling addform
Florian Lindner wrote: Hello, I have an addform registered: addform label=Add Blog Comment name=AddBlogComment.html schema=..interfaces.IBlogComment content_factory=..blog.BlogComment permission=Blog.AddComment / addMenuItem class=..blog.BlogComment title=Blog Comment description=A Blog Comment permission=Blog.AddComment view=AddBlogComment.html / class IBlogComment(IContained): containers(IBlogEntry) name = TextLine( title = uYour name, description = uYour name or nickname, default = uGuest, required = True) email = TextLine( title = uE-Mail, required = False) content = Text( title = uBlog comment content, default = u, required = True) class BlogComment(Contained): A comment to a Blog entry. implements(IBlogComment) name = u email = u content = u but when I call the addform resp. click on the addMenuItem I get an system error: 2007-02-11T19:19:46 ERROR SiteError http://localhost:8080/xgm/Blog/2007_02_10_erster_post/+/AddBlogComment.html ... ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0x9e95b2c, zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/xgm/Blog/2007_02_10_erster_post/+/AddBlogComment.html), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') what do I have misconfigured here? IBlogComment has picked up the fields __parent__ and __name__ from IContained. Try explicitly specifying the IBlogComment fields in the addform directive: set_before_add, e.g. set_before_add=name email content If you add an __init__ constructor to BlogComment then you could use the fields or keyword_arguments instead, e.g. fields=name email content -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: NotYet error when creating content during container creation
Yes, this is what I'd recommend. A handler for an ObjectAddedEvent will always see the object already as part of the object hierarchy (which is, after all, what ObjectAddedEvent is about). I found myself doing this quite often. I use a decorator to make the code read nicer.. class MyContainer(Container): @callafteradd def setup(self) self['subobject'] = SomeObject() self['subobject2'] = AnotherObject() ... def callafteradd(method): Decorator which invokes a method after an instance has been added to a container. caller_locals = sys._getframe(1).f_locals if caller_locals.get('__callafteradd__') is None: caller_locals['__callafteradd__'] = () caller_locals['__callafteradd__'] += (method,) return method @component.adapter(IObjectAddedEvent) def ObjectAddedHandler(event): callafteradd_methods = getattr(ob, '__callafteradd__', ()) for f in callafteradd_methods: f(ob) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3.3.0 creating DTML page TypeError: readline() takes exactly 1 argument (2 given)
David Christensen wrote: zope3-users: I am a newbie running Zope 3.3.0 on FreeBSD 6.2. I'm trying to create a hello, world! home page. When I browse to my Zope instance, log in using the administrator account, drill down to [Top] - ++etc++site - default, choose DTML Page, enter the magic words in the text area, and click Add, my browser indicates error 500 and z3.log says: 2007-03-09T17:55:06 ERROR SiteError http://p3800.holgerdanske.com:80 80 Traceback (most recent call last): File /usr/local/www/Zope3/lib/python/zope/publisher/publish.py, line 126, in publish request.processInputs() File /usr/local/www/Zope3/lib/python/zope/publisher/browser.py, line 263, in processInputs fs = FieldStorage(fp=fp, environ=self._environ, keep_blank_value s=1) File /usr/local/lib/python2.4/cgi.py, line 530, in __init__ self.read_multi(environ, keep_blank_values, strict_parsing) File /usr/local/lib/python2.4/cgi.py, line 650, in read_multi environ, keep_blank_values, strict_parsing) File /usr/local/lib/python2.4/cgi.py, line 532, in __init__ self.read_single() File /usr/local/lib/python2.4/cgi.py, line 665, in read_single self.read_lines() File /usr/local/lib/python2.4/cgi.py, line 687, in read_lines self.read_lines_to_outerboundary() File /usr/local/lib/python2.4/cgi.py, line 715, in read_lines_to _outerboundary line = self.fp.readline(116) TypeError: readline() takes exactly 1 argument (2 given) I've seen this error posted before - but can't recall the details - almost certain it's a bug. Check the collector - and/or install Zope 3.3.1 I'm just fumbling around with Zope, and don't know if I'm using the software wrong or if this is a bug in Zope (or elsewhere). I guess the meta-question is: what's the best way to learn Zope?. STFW, I can't seem to find any Zope 3 tutorials, and the most recent online edition of The Zope Book seems to cover version 2.6. Should I attempt to read/follow that version of the book using Zope 3 and discover the differences, or would I be better off installing Zope 2.6? Zope3 and Zope2 are different beasts. The Zope3 'home' page is http://wiki.zope.org/zope3/FrontPage There's a Zope3 FAQ at http://wiki.zope.org/zope3/FAQ I recommend the book 'Web Component Development with Zope3'. The 2nd edition has just been released. Seriously consider getting it. The author's website is http://worldcookery.com/ and the 'Appetizers' section lists refs to tutorials and getting started with zope3. Unless you need to specifically use Zope2 for some legacy purpose, USE Zope3. You'll be a much better programmer. regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3 and menus
Hi there, I override BrowserMenu from zope.app.publisher.browser.menu and add a entry 'abs_action' to the resulting dictionary. Something like: class MyBrowserMenu(BrowserMenu): def modify(self, menu, request): siteurl = absoluteURL(hooks.getSite(), request) for item in menu: item['abs_action'] = siteurl + '/' + item['action'] submenu = item.get('submenu', None) if submenu is not None: self.modify(submenu, request) def getMenuItems(self, obj, request): menu = super(MyBrowserMenu, self).getMenuItems(obj, request) self.modify(menu, request) return menu browser:menu id=monitor_menu title=menu description here class=.MyBrowserMenu / div id=monitor_menu class=box ul li tal:repeat=item context/@@view_get_menu/monitor_menu a href= tal:attributes=href item/abs_action; title item/description tal:content=item/title/a /li /ul /div Cheers -Tom eXt wrote: Hi I've got a problem with menus. I'd like to define a global menu, and then add some options to it depending on actual context (view registered for specific interface). The problem is that when I define global menu element link like: action=/index.html it generates url which omits my folder structure which shold be: root/my_site/index.html and creates: root/index.html. On the other side when i use: action=index.html the url which is created is always relative. I'd like to be able to define my_site (which is in fact a Site object) to be root for actions. What is the correct solution for that? Should I edit global urls before displaying them (add my_site part)? Look at third code snippet below - it generates urls so I can easly change some strings. Is this a proper solution? My code: Menu definition: browser:menu id=monitor_menu title=menu description here / Global menu action (snippet from worldcookery.com code): browser:menuItem for=* menu=monitor_menu title=Start action=/index.html permission=zope.View / Context dependent action: browser:page name=edit.html for=..interfaces.IMonitorConfDB class=.monitor_conf_db_view.MonitorConfDBEditForm permission=zope.View menu=monitor_menu title=Edit config / I display menu using viewlet with template (iirc code from worldcookery book): div id=monitor_menu class=box ul li tal:repeat=item context/@@view_get_menu/monitor_menu a href= tal:attributes=href item/action; title item/description tal:content=item/title/a /li /ul /div ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] imports cleanup
Hi Christophe, you may want to take a look at pylint. www.logilab.org/project/name/pylint It is a coding standard checker, finding unused imports as well but does much more. Cheers -Tom Christophe Combelles wrote: Hello, As I'm experimenting with various components, I'm adding more and more imports in the beginning of the python files, but at the end, most of them are unused. Is there a tool or a method to automatically clean or detect unused imports ? regards, Christophe ___ 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] Installing Zope / permissions ???
Hi Tobias, you should be able to install a Zope3-server downloaded from zope.org with the well known commands: ./configure --prefix=PATH TO SERVER --with-python=PATH TO PYTHON make make install If you don't know the path to python. try: which python2.4 BTW: You should *NEVER* run Zope as root. Cheers -Tom On Thu, 2007-04-05 at 10:42 +0200, Tobias Daub wrote: Hello Everybody, I'm new to Zope and I just wanted to install it on my providers webserver (Goneo). So I logged in via ssh and did the things from the README.txt. ./configure = wenr OK Python 2.4.3 is installed on that machine Because I don't have root privileges, I changed the installation path to my home dir. The install procedure via python2.4 install.py -q build went OK, too. The test python2.4 test.py -v canceld with no mem for new parser a nd ended in MemoryError. After that I tried to install it via python2.4 install.py -q install --home path and I got the following: Sorry: UnicodeError: (\\N escapes not supported (can't load unicodedata module),) Would be nice, if some can help me! greatings Tobias ___ 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] Arranging widgets in a form / Limit size of input fields
Hermann Himmelbauer wrote: I'd like to know how to arrange (e.g. group) widgets in a form with formlib. One way would be to create a custom template file, where each widget is placed via HTML. However, this is quite some work. I've often done this and it doesn't seem like too much work. But I don't dispute your evaluation. Well, when looking at the template, I roughly have to write this for every widget: div class=label label for=field.name title=The widget's hint tal:attributes=for view/widgets/foo; title view/widgets/foo/hint tal:content=view/widgets/foo/labelLabel/label /div div tal:condition=view/widgets/foo/error tal:content=structure view/widgets/foo/errorError/div div class=field input tal:replace=structure view/widgets/foo / /div Hi Hermann, I started a form layout add-on for formlib, see snippet below.. It's a very rudimentary first cut, and only provides a grid (table) layout. I can't see myself getting any time to work on it in the immediate future. If you think it might be useful I can send you the package (which includes doctests). Regards -Tom class SearchForm(LayoutMixin, form.EditForm): interface.implements(ISearch) form_fields=form.Fields(ISearch) form_fields['results'].custom_widget = HTMLDisplayWidget form_method='GET' form_layout=VertLayout( ).addText(uTraining Guide, ).addWidget('search_type', label=uSelect one of the following items, ).addText(uhr / ).add(GridLayout( ).addText(uSearch Criteria, 0, 0, colspan=5, ).addWidget('region', 1, 0, ).addWidget('institution', 1, 2, ).addWidget('skill', 2, 0, ).addWidget('text', 2, 2, ).addAction('search', 2, 4, ).addWidget('results', 3, 0, colspan=5, label=None, ) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Locatability of schema.Object field
Alen Stanisic wrote: Hi, in the following situation: class ISomeNames(IContained): items = List(... value_type=Object(schema=IName ..) ) class IName(Interface): afield = Choice(... vocabulary=AVocabulary ..) say in the vocabulary I need to look up containment tree but IName object does not have enought context set so I assume schema.Object fields are not locatable. Or I guess they could be, my understanding is that you could also point to an existing persistent object using schema.Object field, which is not really what I am trying to do here. I just want ISomeNames to be composed of list of IName objects. I have read a bit about contained proxies. Is the solution here to wrap IName with this proxy and make it appear as if it is contained by the container of ISomeNames. How would I do that? Or is there a way to refer back to ISomeNames from IName? Also this thread touches on the subject of schema.Object locatability: http://mail.zope.org/pipermail/zope3-users/2006-December/005090.html Hi Alen, I wrote a descriptor for something like this... http://yoma.svn.sourceforge.net/viewvc/yoma/yoma/trunk/site/property.py?view=markup ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Using svn checkout with zc packages
P.S.: I can't recommend easy_install because that will install eggs into the global site-packages location (which is rarely a good idea when you're deploying Zope). Unless of course you use workingenv or virtual python. You can configure the easy_install target location(s) easily enough: http://peak.telecommunity.com/DevCenter/EasyInstall#configuration-files http://peak.telecommunity.com/DevCenter/EasyInstall#custom- installation-locations http://docs.python.org/inst/config-syntax.html For example I use the file ~/.pydistutils.cfg to install all eggs to my 'personal' location: (see: http://peak.telecommunity.com/DevCenter/EasyInstall#mac-os-x- user-installation). [install] install_lib = ~/Library/Python/$py_version_short/site-packages install_scripts = ~/bin Are there shortcomings using these options? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Kupu and Zope3
On 20/08/2007, at 7:45 PM, Jeremy Cook wrote: Is anyone using Kupu (or any other visual editor) with zope3? I saw hints that it might be ported to zope3 or conversely that kupu must die. When I tried installing it under zope3 I didn't get awfully far. Any ideas how to proceed? There's also zope.html which incorporates fckeditor. http://svn.zope.org/zope.html/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Weird error for a certain named attribute
On 18/10/2007, at 11:58 PM, Maken Seteva wrote: Hello, I have a very strange error that I cannot understand. I get an error for one of my attribute only when it is named a certain name! It seems like there is an old implementation of it that is haunting in the background, how is this possible? This cursed name is called tags. This attribute is a list of TextLine. I get the error when I don't add anything to the list in the adding view: TypeError: iteration over non-sequence However, if I rename the attribute to wehoo or really, anything else, I don't get the TypeError and I can add my content object successfully (with an empty list for wehoo). Here's my component: class IFoo(IContained): #... tags = List( title=_(u'Tags'), description=_(u'A list of keywords'), max_length=10, value_type=TextLine(title=_(u'Tag')), unique=True ) #... class Foo(Persistent): implements(IFoo) __name__ = __parent__ = None def __init__(self): #... self.tags = PersistentList() #... No custom widgets used for this field... I tried deleting all .pyc-files and deleting all old Foo objects, and the site i run for testing followed by restarting the server. But adding new Foo objects still don't work. (But renaming tags to anything else and then trying again will succeed). Any ideas? Add: default=[] to your IFoo schema. -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] overriding single resources from resourcedirectories
Hi, is it possible to override single resources from a previously defined resourcedirectory? I have let's say a 3rd party product defining ... resourceDirectory name=mycss directory=resources permission=zope.Public / ... Now I need to override a single css-file provided by the resource-directory. What would the directive be? overrides.zcml: ... resource name=mycss/single.css file=single.css permission=zope.Public / ... I tried that, but without success. Is there a solution beside of copying the whole directory to my new product? Thanks, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Problem running examples from Zope3 book Weiterhausen
Hi, I'm a newbie to Zope and taking my first steps into this wonderful world by going through the book 'Web Component Development with Zope 3' from Philipp von Weitershausen. Up to page 94 I have had little difficulties reproducing the examples. I'm using the downloaded example code as described in the book. I'm running Zope 3.2 on a Windows 2000 machine with Python 2.4 installed. My browser is Mozilla Firefox 1.5.0.1. Real troubles start with the code in paragraph 7.4 which adds a customized list input widget. The browser/widget.pt and browser/sequence.js files run fine when directly invoked from the browser. But when I run it from the Zope instance with the added browser/widget.py and changed browser/configure.zcml it doesn't work. Here is what happens: I copied the downloaded code from the book to C:\Python24\Zope3InstanceWeitershausen\lib\python (this was successful for the previous examples) I start Zope by: C:\Python24\Zope3InstanceWeitershausen\.\bin\runzope I've made sure that C:\Python24\Zope3InstanceWeitershausen\lib\python is in my PYTHONPATH I've deleted C:\Python24\Zope3InstanceWeitershausen\var\Data.fs manually to get rid off previous experiments I start my browser and log on using http://localhost:8080/manage It al looks fine and I have the Add - Recipe button I click on Add Recipe and the screen goes blank displaying: Going back and looking up the error log I see: Traceback (innermost last): Module zope.publisher.publish, line 138, in publish result = publication.callObject(request, object) Module zope.app.publication.zopepublication, line 161, in callObject return mapply(ob, request.getPositionalArguments(), request) Module zope.publisher.publish, line 113, in mapply return debug_call(object, args) - __traceback_info__: bound method +.action of zope.app.publisher.browser.viewmeta.+ object at 0x02E0EAB0 Module zope.publisher.publish, line 119, in debug_call return object(*args) Module zope.app.container.browser.adding, line 128, in action name=view_name) is not None: Module zope.component, line 165, in queryMultiAdapter return sitemanager.queryMultiAdapter(objects, interface, name, default) Module zope.component.site, line 75, in queryMultiAdapter default) Module zope.interface.adapter, line 475, in queryMultiAdapter return factory(*objects) Module zope.app.form.browser.editview, line 64, in __init__ self._setUpWidgets() Module zope.app.form.browser.add, line 49, in _setUpWidgets setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames) Module zope.app.form.utility, line 153, in setUpWidgets context=context) Module zope.app.form.utility, line 101, in setUpWidget widget = widget(field.bind(context), view.request) Module zope.app.form, line 120, in __call__ return self._create(args) Module zope.app.form, line 102, in _create instance = self._widget_factory(*args)TypeError: __init__() takes exactly 3 arguments (4 given) As a newbie this is all too much for me. I've visited the books' website but there are no clues from the errata. I've tried to look into release notes to see if something changed in Zope 3.2 that explains it but no luck. Can anyone help me out? I've tried running other examples form the book past chapter 7 but they also fail probably to my same mistakes. Regards, Tom This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] registerHandler question/problem
Hi this is my first post to this group. I hope someone can help me. I have the following problem using Zope 3.4: I have created a simple handler using the @adapter decorator and register it in the local site manager. The handler works fine but the ZMI tab showing the sites' registrations crashes with a ComponentLookupError in HandlerRegistration. The message comes from @@registrations.html and it appears that my handler should have zope.app.component.browser.registration.ISiteRegistrationDisplay implemented. This however, requires a class. So I created a class with a __call__ method, but I cannot even get it to work as a global handler... :-( Can anyone explain how to register a handler in the local sitemanager without crashing the ZMI registrations tab? Even a simple handler in a class using implements/adapts with ZCML configuration in stead of the usual @adapter decorator approach would be very helpful. Thanks, Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users