Re: [Zope3-Users] Getting params in a request
Hi, On Wed, Jul 12, 2006 at 02:50:47PM +, Stéphane Brault wrote: > Hi, > for my application I need to let another site redirect its user to one of my > page with an operation and some parameters, giving it this address: > http://www.mysite.com/mypage?myOperation¶m1=vaue1¶m2=value2 > The values are filled by the other site. > How can I do that ? class MyPageView(BrowserView): def __call__(self): if 'myOperation' in self.request.form: param1=self.request.form['param1'] param2=self.request.form['param2'] do_something(param1,param2) MyPageView has to be either the default view asociated to the 'mypage' object or a view called 'mypage' associated to the RootFolder object. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: A gentle push in the right direction needed
Hi, I wrote a howto about the object schema and how to make a widget for those objects. It's partly in english: http://zope3.mpg.de/cgi-bin/twiki/view/Zope/KomplexerContent Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Editing a Page on zope.org
Hi, I wrote some some howtos and receipes about Zope3 and would like a link on http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/FrontPage to point to those pages. I got an account for zope.org, I logged in but I don't know how to edit this page. Is this a permission problem? If "Yes", could someone please add the Item "Glossary & Cookbook (German)" as link to http://zope3.mpg.de to the topic "User documentation"? Thank you, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] PAU, how to grant roles to groups
On Fri, Sep 08, 2006 at 10:12:34AM +0400, Denis Shaposhnikov wrote: > > "Stephan" == Stephan Richter <[EMAIL PROTECTED]> writes: > > Stephan> You cannot grant permissions via ZCML to principals that are > Stephan> located in the ZODB. You have to use the "Grant" view of the > Stephan> folder for this. > > Oh, that's a bad news. Am I right that Zope3 have principals either > ZODB or ZCML? Principals in Zope3 are identified by simple text strings (e.g. zope.Manager). When a request is processed by the zope server, it tries to find a IAuthentication utility which has a method to provide credentials (username, password) returning a principal object which is not persistent (-> changing attributes on that object wont affect anything after that request). Problem ist: When the ZCML-tree is parsed, any -statement tries to verify, if a given principal exists. This verification fails for principals provided by a a PAU- or another Site-Manager-registered IAuthentication utility. If you want to assign a permission to a principal for the whole zodb, just do that for the root folder and it will be inherited down the traverse path. Example: from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager from zope.app import zapi root=zapi.getRoot(context) ppm=IPrincipalPermissionManager(root) ppm.grantPermissionToPrincipal('zope.ManageContent','my.principal') The permission-principal-assignment is stored as a simple text-tuple - there's no check for validity of wither the principal's or the permission's id. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] How to make a new namespace for pagetemplates?
Hi, my employer want to have all external links marked with a small icon telling anonymous users from the internet that everything behind given links is beyond our responsibility. Currenty I have to do something like that: ... which doesn't really looks like a nice method to produce i.e. this: http://example.com";>This is an example company The 'linkwriter' chooses the a-tag's class and title according to the domain of the href. I would like to make writing those pagetemplates a bit easier - maybe like that: How complicated is it to write an additional pagetemplate namespace which is able to "postprocess" a tag, after 'tal', 'i18n' and 'metal' did their work? Thank you, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to make a new namespace for pagetemplates?
Hi, On Fri, Sep 08, 2006 at 12:54:14PM +0200, Martijn Pieters wrote: > On 9/8/06, FB <[EMAIL PROTECTED]> wrote: > >my employer want to have all external links marked with a small icon telling > >anonymous users from the internet that everything behind given links is > >beyond our responsibility. > > Why not use a piece of javascript to do this? See the linkpopper > product on plone.org for a way to process all links in a page and > process them. That product makes external links open in a new window, > but the code should be easy to alter. Thank you for the hint. But there are several reasons for not using JS: * One of the constraints of that site is javascript being optional. Problem ist: marked links are mandatory - they have to be marked even with javascript turned off. * I'd like to have a tag-postprocessing namespace for some other reasons, too - e.g. for a printing-view that automatically creates a list of links at the end of the page. * I'd like to know, how to make a new pagetemplate namespace :-). Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: How to make a new namespace for pagetemplates?
Hi, On Fri, Sep 08, 2006 at 01:45:45PM +0200, Philipp von Weitershausen wrote: [snip] > Write a new TALES expression type (like string: or python:) that constructs > link tags. > This could like: > > > link goes here > > > The link: expression would split the argument string, take the first part as > the URL and > the second one as the link description. Both would be fed through the > PathExpression so > that they're evaluated. > > Custom TALES expression types are components providing > zope.tales.interfaces.ITALESExpression. Look at zope.tales.expressions for > the > implementation of the standard TALES expressions. Perfect :-) . That's what I'll do. Thank you, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Using ZCML for defining global constants ?
Hi, On Mon, Sep 11, 2006 at 01:19:31PM +0530, Baiju M wrote: > Just added this to FAQ: http://kpug.zwiki.org/Zope3Faq I did the same - in german: http://zope3.mpg.de/cgi-bin/twiki/view/Zope/CookBook#Globale_Konfigurationsparameter Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with containers
Hi, On Thu, Sep 14, 2006 at 04:38:15PM -0700, Rob Campbell wrote: > Hello, > > I just recently started trying out Zope 3. My first test project is a > few containers that can contain other containers or an object. They are > laid out as follows: > > FosterRecord > -> FosterSource > -> Foster > -> FosterGroup >-> Foster [snip] > I start adding containers and objects to create this structure through > the ZMI. When I am ready to add a FosterGroup or a Foster to a > FosterSource, I do not get any options for them in the add menu. I > haven't been able to find what is causing it. I would guess it has > something to do with the constraints. My guess is that you forgot to define s for your classes. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] __init__ method never called?
Hi, On Mon, Sep 18, 2006 at 03:37:28PM +0100, John Smith wrote: > Hi everyone! > > the class > zope.app.publisher.browser.fileresource.FileResource > inherits from BrowserView and Resource in that order. > > As far as I can work out, the __init__ method in > Resource > (zope.app.publisher.browser.resource.Resource) is > never called. (Please correct me if I'm wrong, I'm not a Python guru :-) ) Whenever you inherit from two classes, only the first class' __init__ method is called implicitely on create of a new instance. If you want both base classes' init method to be called, do something like this: class MyView(BrowserView,Second): def __init__(self,context,request): BrowserView.__init__(self,context,request) Second.__init__(self,context,request) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] __init__ method never called?
Hi, On Tue, Sep 19, 2006 at 04:53:45AM -0400, Stephan Richter wrote: > On Tuesday 19 September 2006 03:47, FB wrote: > > (Please correct me if I'm wrong, I'm not a Python guru :-) ) [snip] > >>> class Join(First, Second): > ... def __init__(self): > ... print 'init 3-before' > ... super(Join, self).__init__() > ... print 'init 3-after' > ... > >>> Join() > init 3-before > init 1-before > init 2-before > init 2-after > init 1-after > init 3-after > <__main__.Join object at 0xb7b5fb6c> > >>> > Thank you for the clarification, Stephan. I know the meaning of 'super' a lot better now. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Adding another "special" traversal component type
Hi, I'd like to make URLs like http://servername/~username possible on my Zope3 server which should instantly redirect a visitor to one of my site user's home pages. Is this possible? Of course, the answer ist yes (by patching zope.traversing.adapters.traversePathElement) - but is there a more Zope3ish way to do that? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Adding another "special" traversal component type
Hi, On Wed, Sep 20, 2006 at 03:49:07PM +0200, FB wrote: > Hi, > > I'd like to make URLs like > > http://servername/~username > > possible on my Zope3 server which should instantly redirect a > visitor to one of my site user's home pages. > > Is this possible? Of course, the answer ist yes (by patching > zope.traversing.adapters.traversePathElement) - but is there > a more Zope3ish way to do that? Thanks for all the tips. I'm going to implement an alternative IPublishTraverse adapter. Using apache might be an option but I'm writing an application which should depend on as few other applications as possible which is why I'd like not to use apache if I don't have to. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Logout
Hi, On Thu, Sep 21, 2006 at 07:25:06AM -0500, David Johnson wrote: > Does anyone know how to logout? We've been using logout.html as the logout > page for Zope Realm Basic Auth, and it does not seem to log us out. We're > using IE 6. It's not possible to log out when Basic Auth is used (except if you want your users to install a fancy browser extension like Webdeveloper for Firefox). Use a different auth method (=PAU credential plugin) like cookie-base-auth. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: There aren't IDict widget ?
Hi, On Fri, Sep 29, 2006 at 10:20:01AM +0200, KLEIN Stéphane wrote: > 2006/9/29, KLEIN Stéphane <[EMAIL PROTECTED]>: > >2006/9/29, KLEIN Stéphane <[EMAIL PROTECTED]>: > >> Hello, > >> > >> in one content component I've switch from IList to IDict schema and I > >> note than IDict widget don't exist. It's normal ? if yes, why ? > > > >I see that : http://mail.zope.org/pipermail/zope3-users/2006-June/003720.html > > > > In mail http://mail.zope.org/pipermail/zope3-users/2006-June/003720.html > I don't know where put the last part : This was just a fix of the (formerly?) buggy Dict schema object. Just copy it into a seperate python file and instead of defining class MySchema(Interface): Dict(...) use class MySchema(Interface): FixedDict(...) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Get Started
Hi, On Tue, Oct 10, 2006 at 05:59:55PM -0300, Luiz Fernando Bernardes Ribeiro wrote: > Hello all, > > Is there any tool to automate the bootstrap of a new project? Something like > ArcheGen XML? To generates all the initial Interfaces, Implementation > classes and the configure.zcml? Maybe. I wrote a script which creates a new application but I don't know, if it's still working with a current Zope release. https://svnserv.cbs.mpg.de/svn/edv/EDV/zope3-mpgsite/lib/python/mpgsite/tools/zag I've not used it for a long time. There are no warranties but feel free to try. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] error on registration in the zmi
On Sun, Oct 15, 2006 at 05:58:26PM +0200, Christophe Combelles wrote: > each time I want to register any object from the ZMI I get this error. > (zope 3.3.0 Python 2.4.4c0) > Do you have any clue? Yes. 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 Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ZCML help
Hi, On Mon, Oct 16, 2006 at 10:08:34AM -0500, Perry Smith wrote: > I'm new to Zope but I've been programming for 25+ years. I've read > Weitershausen's book and I'm 10 > chapters into the Zope 3 developer's handbook. I'm struck by its statement > that beginners find ZCML > hard. That is true for me too. > I keep reading and reading instead of doing which is not like me. I > perceive ZCML as bag of magic. By that I mean that usually I can clearly > define a starting point and an ending point and a hazy path between the > two and I set off about my way. But with Zope 3, I do not have the > starting point and so I do not have the hazy path. Each directive seems > unique to the particular example in the book. I'm unable, for some > reason, to step back and see how ZCML is generally applied. I'm not sure > if it is me or the books or what. > > I'm wondering if others are or have been in my situation. If so, can you > offer any advise or particular things to read that will help me out. I've been in that situation. To help all the newbies after me, I try to write down as much as possible on zope3.mpg.de - which is unfortunately in german. I'll try to explain ZCML in some sentences: Every class you use (e.g. MyCalendarClass) has to be security-described in ZCML. security declaration are working like this: * This is my class 'MyCalendarClass' * to use attribute "getNextEvent", "title" you need permission 'zope.Public' * to use attribute "cleanupOldEvents()" you need permission 'calendar.Writer' * to *write* to attribute "title" you need permission 'calendar.Writer' Hints: * to make life easier, you're allowed to use '' to declare security for a bunch of attributes (the ones define in the interface) at once. * If your class is a container, you have to describe the mapping functionality, too. Mapping functionality in Python can be expressed by attributes. e.g. "calendar['myevent']=event" is the same as "calendar.__setitem__(event)" . Someone wrote all the mapping functions in interfaces - e.g. zope.app.container.interfaces.IWriteContainer (which contains all methods necessary for writing). * security declarations are applied when an instance of the class is restored from the ZODB. That's it for your content classes. Remember: If you write utilities or adapter classes, you sometimes want to security-declare those classes, too. Many objects (usually more than you think) in Zope3 are adapters or utilities. In ZCML you'll have to define factories (e.g. callable python objects which return an instance of the adapter/utility you want to get) for them. The first adapter I used (I didn't even know, it's one...) was a ''. This ZCML-statement just defines an adapter for (context,request) to IBrowserView which is callable and returns a nice HTML page. All the stuff in the '' statement configures the factory of the browserview to i.e. include a custom template. '' is nothing more than a '' statement in disguise which makes you lifer easier. The first utility I used was a vocabulary which was a factory class (a class implementing IVocabularyFactory). This class created a static factory that I needed to select one of four rooms in our building. At this time, I needed the '' statement - today this is done via '' which does exactly the same. Most of the other stuff in ZCML are disguised utility- or adapter-statements, too. Most of the problem I had, were eventually me not knowing, which interface I needed, that I didn't know what I was actually doing (-> vocabulary: writing an utility) or that I didn't know something very special I needed was already provided by Zope (e.g. internationalized country names). HTH Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Setting custom content type when publishing a resource
Hi, On Tue, Oct 17, 2006 at 12:53:48PM +1300, Andrew Groom wrote: > Hi All, > > I want to do something that feels like it should be really simple: set a > specific content type when > a particular resource is published (a Firefox extension, a binary .xpi file > if it helps). Any ideas > how I could do that ? I've tried playing round with variations of: > > class XPIPublisherView (BrowserView): > > def __init__ (self, context, request): > self.context = context > self.request = request > > # Override the default publication so we can set the content type on > the way out. > pub = XPIPublication('') > self.request.setPublication(pub) You should do this in the __call__() method. This is the default view of an advanced IFile implementation of mine: class AutoFileView(BrowserView): def __call__(self): self.request.response.setHeader('Content-Type', self.context.contentType) self.request.response.setHeader('Content-Length', self.context.getSize()) return self.context.data Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Custom DateWidget with Month/Day/Year
Hi, On Mon, Oct 16, 2006 at 05:46:29PM +0200, Thierry Florac wrote: [snip] > Installation is fine, as well as widget, but I can't get dates displayed > or entered in a french way (DD/MM/). > I've tried to modify browser settings as well as a few parameters, but > nothing is doing it correctly (and when date is displayed correctly in a > form, Zope 'normally' says that dates are not correctly formatted while > submitting !). Hmm ... it took me 10 seconds to change the format to DD/MM/Y. Have a look at datetimewidget.py, look for '_format' . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Setting custom content type when publishing a resource
Hi, On Wed, Oct 18, 2006 at 12:45:50PM +1300, Andrew Groom wrote: > FB wrote: > >Hi, > >On Tue, Oct 17, 2006 at 12:53:48PM +1300, Andrew Groom wrote: > >>Hi All, > >> > >>I want to do something that feels like it should be really simple: set a > >>specific content type when a particular resource is published (a Firefox > >>extension, a binary .xpi file if it helps). Any ideas how I could do > >>that ? [snip] > >You should do this in the __call__() method. This is the default view of an > >advanced IFile implementation of mine: > >class AutoFileView(BrowserView): > > def __call__(self): > > self.request.response.setHeader('Content-Type', > >self.context.contentType) > > self.request.response.setHeader('Content-Length', > >self.context.getSize()) > > return self.context.data > > Thanks, Frank. The bit I'm missing now is the ZCML to hook it all together. > Do I use a > browser:resource ? If you could give me an example, that'd be great. No - it's a simple BrowserView. Just use a standard-page-statement: BTW: browser:resource is used for 100% static content (CSS-files, icons, images, ...). Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Setting custom content type when publishing a resource
Hi, On Wed, Oct 18, 2006 at 07:58:45PM +1300, Andrew Groom wrote: [snip] > for="*" > name="vortexgdna.xpi" > class=".xpipublisher.XPIPublisherView" > permission="zope.View"/> > > > > (It complained if I didn't have the "for" attribute in there, btw) Sorry, it was late (or early?)... The browserview code i sent you, was copy'n pasted from my application. You have to customized it to your needs. context is in case of my autofile object a persistent non-container object containing a single file which is stored in the data attribute. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] how to set predefined values on newly created content object
Hi, On Wed, Oct 25, 2006 at 05:11:44PM +0200, Dominique Lederer wrote: > hello > > i would like to set predefined metadata, when i create a new content object. > > from my point of knowledge i could to this with a custom factory or by > listening to events. > > is there any other possibility to to this, mabe somehow in the interface? Taking into account that creating content objects can be done manually in python, i'd use a view like this on the container of the new object: predefined={ 'set1':{ title:'something', otherfield:'foo', [...] }, 'set2':{ title:'something else', otherfield:'bar', [...] }, [...] } class CreateView(BrowserView): def __call__(self): if 'create' in self.request.form: if 'paramset' in self.request.form: paramsetname=self.request.form['paramset'] if paramsetname in predefined: newobj=MyClass(**paramset) name=INameChooser(self.context)('',newobj) self.context[name]=newobj In this case the view could i.e. react to some html-form which presents a , returning either 'set1', 'set2' , [...] . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Open Ofice and Zope
Hi, On Fri, Nov 03, 2006 at 01:01:12PM -0600, Sreeram Raghav wrote: > Hello, > Here I have a starnge problem. > I created a knowledge base of a certain bunch of documents(PDF, MSWORD, > OO) > My question is when I click on the link to that document using zope(ZMI), it > prompts me to use a client side application. > But I was wondering if I can use the server side open office application to > open all the word and open office applications. Do you want to display those files or edit them? Displaying them is just a question of writing a view which uses a clever html converter for Openoffice-, Word-, ...-files . For word, you can use 'wv' which contains a program called wvhtml. I don't know a converter for openoffice but it's file's XML structure Should make it easy to write one. If you want to edit files server based, you'll have to write some kind of AJAX-application, which I consider *very* complicated. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Extending IImage
Hi, On Fri, Nov 10, 2006 at 10:32:13AM +0100, Nordmann Arne wrote: > Hi guys, > > > > I'm trying to extend the Interface IImage by a title and a caption. My > plan was to use zope.app.file.interfaces.IImage as base interface and > zope.app.file.Image as base class, but that doesn't work. Every time I > submit the add form, I get the following traceback: > > [...] > > File "C:\Python24\Lib\site-packages\zope\tales\tales.py", line 696, in > evaluate > > return expression(self) > > File "C:\Python24\Lib\site-packages\zope\tales\expressions.py", line > 205, in __call__ > > return self._eval(econtext) > > File "C:\Python24\Lib\site-packages\zope\tales\expressions.py", line > 199, in _eval > > return ob() > > File "C:\Python24\Lib\site-packages\zope\app\form\browser\add.py", > line 62, in update > > self.createAndAdd(data) > > File "C:\Python24\Lib\site-packages\zope\app\form\browser\add.py", > line 120, in createAndAdd > > field.set(adapted, data[name]) > > File "C:\Python24\Lib\site-packages\zope\schema\_bootstrapfields.py", > line 183, in set > > setattr(object, self.__name__, value) > > File "C:\Python24\Lib\site-packages\zope\security\checker.py", line > 488, in check_setattr > > self._checker2.check_setattr(object, name) > > ForbiddenAttribute: ('contentType', at 0x02FB8CB0>) > > > > What's the problem? Why is contentType forbidden? "Data" and > "contentType" are valid attributes of the base interface > "zope.app.file.interfaces.IImage". You need a seperate -Statement for any class - no matter, which interface(s) it provides. The require-attribute 'like_class' might come handy... However - I've had your problem to (needed to provide 'alt' and 'description'- -attributes to be XHTML-compliant...). The solution is rather simple: * dc=IZopeDublinCore(myimageobject) (see zope.dublincore) * title-information is in dc.title * caption is in dc.description * an additional view 'longdesc.txt' for IImage provides content of dc.description as plain text This way you can use original image-class. HTH, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Extending IImage
On Fri, Nov 10, 2006 at 02:42:37PM +0100, FB wrote: > You need a seperate -Statement for any class - no matter, which > interface(s) it provides. The require-attribute 'like_class' might come > handy... Sorry for my poor english: "for any class" is wrong. Correct is "for *every* class". Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Comflicting security annotations
Hi, what is Zope supposed to do, when there are conflicting security annotations applied to an object? I'd like to make an object inaccessible - except for members of a given role. This is how it should look like: grantPermissionToRole('zope.View','role.admins',Allow) denyPermissionToRole('zope.View','zope.Anybody',Deny) Is this possible? If not, why? Maybe there's a more elegant solution? 'zope.Anybody' is defined as a "group" in etc/principals.zcml. Can I use it like a role? Is there a role, any anonymous user *and* any authenticated user is automagically assigned to? Thank you for any help. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Utilities naming convention
Hi, On Thu, Nov 16, 2006 at 04:09:52PM -0400, David Pratt wrote: Probably should > have clarified - I am referring to Utility container names not anything to > do with Python coding standards. None that I'm aware of. Only the title of the utility's registration matters for your application - which is '' in very often. The contained-name is fully independent from the registration's title. Choose whatever you want. Whenever a part of your application has to link to a utility of yours, it should use zapi.absoluteURL(zapi.getUtility(IMyUtility),request) which makes knowing the URL unneccessary. Regards, Frank PS: I know, zapi is deprecated - but it's so convenient :-) ... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] custom widgets (IDisplayWidget)
Hi, On Sat, Nov 25, 2006 at 04:17:24AM +0900, Hassan Alirezaei wrote: > Hello guys, > > I have a custom widget and I cannot manage to have a custom way of displaying > it after > editing. > as far as I know, I should be registering the view for > form.interfaces.IDisplayWidget(for display) and > form.interfaces.IInputWidget(for > editing). > I use the following zcml lines: > > provides="zope.app.form.interfaces.IInputWidget" > for="..interfaces.II18N" > factory=".widgets.SimpleI18NInputWidget" > permission="zope.Public" /> > > > provides="zope.app.form.interfaces.IDisplayWidget" > for="..interfaces.II18N" > factory=".widgets.I18NSimpleDisplayWidget" > permission="zope.Public" /> This looks familiar :-) . I don't know, if you used my I18NSimpleDisplayWidget. If you do: I can't remember ever using this one - maybe it's not working as expected. In most cases, I needed those multilingual fields in page template which I used a tales-namespace-adapter for. I admit that mpgsite.i18n is a mess. I'm currently moving all the i18n-stuff into a different package (fb) which is much smaller than mpgsite. fb.i18n has some additional advantages: * a special class is used as i18n-container (not a dict anymore). This class knows how to extract language versions, does some other fancy stuff and behaves like a dict otherwise. * One language is marked as the "reference language" now * a dedicated class makes it easy to i.e. extract all i18n-objects from the *whole zodb* and make some poor guy translate them. * Documentation is in english * dependencies are clear: * fb.fields: for displaying fancy help in edit forms * fb.skin's header-viewletprovider which is easy providable by your own skin, too * fb.searchengines: for automatically presenting all language versions to user agents identified as search engines (I asked a google-guy: It's ok to do so). The fb-package is available via svn here: https://fbo.no-ip.org/svn/fbo/fb The package is not complete, yet. But it will be at the end of the next week. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] custom widgets (IDisplayWidget)
Hi, On Sun, Nov 26, 2006 at 01:13:43AM +0900, Hassan Alirezaei wrote: > Sascha Ottolski wrote: > >the above seems to build upon an interesting looking package z3c.language: > > > >http://svn.zope.org/z3c.language/trunk/src/z3c/language/ > Thanks for mentioning. > Back to the source of the problem. Maybe I am getting all this wrong. > Alright, one simple question: > -- > what happens when you add an object which uses a widget: > >homepage = URI(title=_("HomePage"),required=False) > > and then call that widget by the following line of zpt : > >some > > Isn't it that a view that is registered for the zope.schema.URI like the > following should be called No widget is called. Problem is, there's no schema information contained in "context/homepage". What the template engine does is basically str(context.homepage) and context.homepage is most likely just a plain string (like BytesLine, DottedName, ...) without any interfaces, zope could adapt. This is why i "invented" a tales namespace. Using the fb-package this example would do something useful: 'fbi18n:text' might be doing more than you want. If it detects a search engine spider, it presents all language version in separate span-tags (incl. lang-attributes). 'fbi18n:simpletext' just includes the best matching language version. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] custom widgets (IDisplayWidget)
Hi, On Sun, Nov 26, 2006 at 03:33:06AM +0900, Hassan Alirezaei wrote: [snip] > Just one last question. if the template just uses str() then what does the > following zcml do? it is in the standard zope3 distribution under the > zope/app/form/browser/configure.zcml and I didn't notice any problem even > when i removed it. Is it just some irrelevant piece Usually you don't need displaywidgets. But they're handy if you e.g. want to view an object's content knowing the schema interface without any template. The browser:schemadisplay zcml-directive does that. > This sounds really cool. I am really unfamiliar with namespaces though. > can you please tell me where in fb package (or mpgsite package) you define > this namespace. mpgsite uses two rather big tales-ns-adapters (mpg, mpgi18n), defined in mpgsite.tales. fb's approach is more modular. The i18n-ns-adapter's logic is in fb.i18n.tales, the registration is done in fb/i18n/configure.zcml . How those adapters work and how to write them yourself is explained in Stephan Richter's book. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] formlib widget
Hi, On Wed, Nov 29, 2006 at 06:37:53PM +0100, Dennis Schulz wrote: > Hi, > > in a formlib based form I would like to have more control over the rendering > of the widgets. > is it possible to call widget with a specific name directly instead of > running through all on a repeat > loop? > for example > > > > I saw that there is a get method but I can't access it form the page template. The w1-assignment won't work because you mixed a path and a python expression. Use tal:define="w1 view.widgets.get('1')" . I wrote a small "Framework" to make template based formlib forms easier. Have a look at fb.fields ( svn at http://fbo.no-ip.org/svn/fbo/fb ). Unfortunately it's not well documented, yet. fb.test is a simple demonstration object using a slighty more powerfull edit/addform than the one provided by fb.fields. It uses fb.i18n.browser.(I18NEditForm|I18NAddForm) instead of fb.fields.browser.(EditForm|AddForm) . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Multiple zcml-overrides of the same component
Hi, I've got a Package B depending on a Package A - both of them are zcml-overriding an adapter which is originally defined in zope itself. Unfortunately, zope doesn't seem to like that - Package B's override causes a ConfigurationConflictErrorwhich which it shouldn't - because the adapter is defined via override, right? Is this a bug in zope or did I miss something? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Registered utility is never found
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',u"no 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. Doesn anyone have an idea, what can cause such an error? Regards, Frank ___ 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, On Mon, Dec 11, 2006 at 11:41:25PM +0100, David Johnson 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) ? > It's been my experience this is caused by registering with a name rather than > leaving the registration > blank. (This confused me for the longest time). As shown in the sample code, the registration is done with name='' . Regards, Frank ___ 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, 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',u"no > > 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
Re: [Zope3-Users] Registered utility is never found
Hi, On Tue, Dec 12, 2006 at 01:54:01PM +0100, Tom Gross wrote: > 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 :-). it verifies successfully. This is the *whole* class ... class InitIndicator(Contained,Persistent): implements(IInitIndicator) def __init__(self,application='',url='',description=u''): self.application=application self.url=url self.description=description ... this is the interface ... class IInitIndicator(Interface): """A utility that is registered, when a application is initialized""" application=BytesLine( title=_(u"Application id"), description=_(u"Python package of the application which initialized the site"), required=False ) url=URI( title=_(u"Homepage"), description=_(u"Homepage of the initializing application"), required=False, ) description=TextLine( title=_(u"Short description"), description=_(u"Short textual description of the application"), default=u"" ) ... and this is all zcml related to this class: Yet, that's *really* the whole thing. There are some more browser-related zcml-statements which I added when I realized that it just didn't work :-( . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael 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. > > > > > traceback, please. Hmm ... how? It just doesn't return the utility as expected (it returns None). There is no error shown in any way. I used pdb to trace the problem down to zope.component.registry.queryUtility . The call to self.utilities.lookup returns None but should return a persistent instance of my InitIndicator class. The call to lookup() is not tracable - I guess it's written C(|++) . However - watch this: > /ZOPE/zope3/src/zope/component/registry.py(132)queryUtility() -> return self.utilities.lookup((), provided, name, default) (Pdb) [reg for reg in self.registeredUtilities() if reg.provided is IInitIndicator] [UtilityRegistration(, IInitIndicator, u'fb', initindicator, '')] (Pdb) self.utilities.lookup((), provided, name, default) (The initindicator utility is registered but lookup() can't find it.) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
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: (, None) Regards, Frank ___ 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, On Tue, Dec 12, 2006 at 04:14:31PM +0100, David Johnson wrote: > Try: > -- > utils = zapi.getAllUtilitiesRegisteredFor(IYourInterface) > for util in utils: > print util > -- > > You can list all the returned utilities. See if your utility is returned, and > see what name it is > registered under. If not, try with a known interface. Can you provide the > results here? That seems to be ok: (Pdb) zapi.getAllUtilitiesRegisteredFor(IInitIndicator) [, ] (Pdb) The first one was created by the -statement in zcml and should be superseded by the second one which is persistent in the site manager. Regards, Frank ___ 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, On Tue, Dec 12, 2006 at 12:39:37PM -0500, Benji York wrote: > Tom Gross wrote: > >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) > > In other words, the name of an unnamed utility isn't None, but the empty > string. That's not the problem. I tried None (but forget to remove it later) because it wasn't working in the first place. Regards, Frank ___ 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, On Wed, Dec 13, 2006 at 12:09:16PM +0300, Garanin Michael wrote: [snip] > Problem solved or no? If "no" then traceback please (after call > zapi.getUtility(IInitIndicator) ). It's working now. I'm doing some more tests because it was working yesterday for some minutes and somehow broke again (without a restart of zope!) or any change on the registration. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ComponentLookupError
Hi, On Wed, Dec 13, 2006 at 09:40:51PM +0100, David Johnson wrote: > I'm very confused by the following error. Whenever I add certain content > components I get the > following error when add form is generated (I'm using standard addform). > > ComponentLookupError: ((, > URL=http://192.168.81.89:8090/CRM/Vanderbilt/@@+/action.html>), > zope.app.form.interfaces.IInputWidget>, u'') > > I am not sure where to go with this. I have three different instances of > Zope and two > generate this error and one does not. The object listed in the error is not > the same between > content types, although it is consistent within a content type. AFAIK the data type Decimal was included into zope some months ago. Maybe two of your zope instances are outdated. Regards, Frank ___ 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, On Mon, Dec 11, 2006 at 12:58:21PM +0100, 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) ? It's strange - I installed the package on a different computer and wasn't able to reproduce the problem in any way. After I re-checked-out zope, my packages, some other stuff, recompiled, ... the problem was gone on the first computer, too. Thank you for all your help. I'll keep the list informed, if the problem re-occurs. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] proxied list object in a schema
Hi, On Sun, Dec 17, 2006 at 02:21:03PM +0100, Tim Terlegård wrote: > Would someone like to explain how to use a list in a schema object > without getting ForbiddenAttribute? This is my use case. > > class IChat(Interface): > messages = Attribute('Chat messages') > > class Chat(Persistent): > def __init__(self): > self.messages = persistent.list.PersistentList() > > > > > try that: class MyList(persistent.list.PersistentList): pass ... You should find the necessary interfaces for your s in zope.interface.common.mapping. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to get PAU working?
Hi, On Wed, Dec 20, 2006 at 12:26:55AM +0200, Jonas Jarutis wrote: > Hi, > > I'm trying to set up a user folder for my site, but i cant get the PAU to > work. > I add the Pluggable Authentication Utility object, register it, add > PrincipalFolder and SessionCredentials plugins and register them. Add > a user in the Principal folder. But then i try to login, i just get > redirected to the same login form and nothing happens. > What else do i need to do? This is what has to be done (in the right order!): 1. Add a PAU 2. Make sure, the PAU knows some users - e.g. this way: 1.Add a principalfolder 2.Add a principal into the folder 3.Configure the PAU to use the principalfolder 3. Make sure, the PAU is able to extract the credentials correctly (Session-Credentials are usefull for that) 4. Register the PAU Once the PAU is registered, the default IAuthentication utility which provides all the zcml-predefined principals becomes invisible (speak: "useless"). This means, you don't have a manager any more and you're unable to unregister the PAU again. For that reason, I wrote a Auth-Plugin which is like a principalfolder but all principals defined there are managers. However: I wrote a Mini-Howto on how to remove the registration of a PAU manually. Unfortunately it's in german: http://zope3.mpg.de/cgi-bin/twiki/view/Zope/ZodbMagic#RemoveRegistration -> Please correct me if I'm wrong. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zc.relationship or hurry.query and global intid utility
On Sat, Jan 06, 2007 at 08:14:52PM +0200, Gabi Shaar wrote: > hi. > i am trying to use zope 3.3.0 > > first somebody correct me if i'm wrong. > > getUtility(IIntIds) looks for an intid utility registerd in the global site > manager. > if i supply a context, then it looks in the local site. > > i am trying to use zc.relationship and hurry.query. both seem to look for a > globally > registered intid/catalog utility (at least as i understand it). i can only > wrap my brain > around how to create a local intid/catalog utility. > > could somebody point me at a simple example of how to create the intid > utility these packages > are looking for ? Go to the site manager: http://zopeserver/++etc+site/default create a IntId-Utility by selecting it from the "Add object" menu. Change to the newly create intid, select the "Registration" tab and add a registration. The next time, getUtility(IIntIds) should return that object. This utility is the one thing you should create before any other object because objects created prior to this utility will never have a unique ID. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] question about a constraint conflict
Hi, On Sat, Jan 06, 2007 at 01:35:35AM +0100, Christophe Combelles wrote: > Hello > > I define the following interfaces: > > class IFoo(Interface): > pass > class IBar(Interface): > pass > > class IFooContainer(IContainer): > contains(IFoo) > class IBarContainer(IContainer): > contains(IBar) > > Then I would like to configure a class Test to to be both a FooContainer and > a BarContainer: > > > > > > > Then I define AddMenuEntries for Foo and Bar implementations. > > This does not work and as a result I only get Foo in the Add Menu. If I > switch the two > implements zcml directives, I obviously get only Bar. > > Is there a solution to configure a class to be both a FooContainer and a > BarContainer with > constraintment ? (I would like to avoid dependencies between Foo, Bar and > Test.) IHMO you should use the containers()-statement on IFoo and IBar instead of contains() on their containers. Even if the contains-constraints of IFooContainer and IBarContainer would be merged somehow on the Test-class, it wouldn't behave as you expect: The contains()-statement can be read as "mustn't contain anything but...". Mixing those two constraints depending on two different contained interfaces would result in "Can't contain anything.". This makes sense, if you have classes, relying on self.values() returning *nothing* but objects implementing the given interface. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] question about a constraint conflict
Hi, On Sun, Jan 07, 2007 at 02:10:20PM +0100, Christophe Combelles wrote: [snip] > I understand there is an inconsistency between these two interfaces, and this > is not a correct solution. > But using just containers() on content objects doesn't prevent their > containers > >from displaying everything in the Add Menu. > It just prevents from adding these objects in other containers. You could use a another interface (i.e. IForOrBar) and something like class IFoo(IFooOrBar): pass class IBar(IFooOrBar): pass class IFooContainer(Interface): contains(IFooOrBar) class IBarContainer(Interface): contains(IFooOrBar) class IFooBarContainer(IFooContainer,IBarContainer): pass This way, Foo and Bar have to depend on another package (The one containing IFooOrBar). Neither does this package need to know anything about IFoo or IBar, nor does IFoo have to know anything about IBar or vice versa. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to get PAU working?
Hi, On Mon, Jan 08, 2007 at 02:38:30AM -0500, Stephan Richter wrote: > On Wednesday 20 December 2006 01:45, FB wrote: > > Once the PAU is registered, the default IAuthentication utility which > > provides all the zcml-predefined principals becomes invisible (speak: > > "useless"). This means, you don't have a manager any more and you're unable > > to unregister the PAU again. > > Huh? I have never experienced this. We are using local authentication > utilities, but I always test with the globally defined manager (if I am not > interested in checking security). Hmm ... I've had this problem multiple times. Whenever the Pau was registered and wasn't able to authenticate a manager, I had to use 'zopectl debug' and unregister the pau manually to get manager access again. This seemed to be ok, because a registered local pau overrides the global IAuthentication utility. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How to get PAU working?
Hi, On Tue, Jan 09, 2007 at 07:47:23AM -0500, Stephan Richter wrote: > On Tuesday 09 January 2007 04:56, FB wrote: > > This seemed to be ok, because a registered local pau overrides the global > > IAuthentication utility. > > But it is the local IAuthentication utility's responsibility to delegate the > request to the next utility higher up, if it cannot give an answer. Some of Pau's methods (e.g. 'getPrincipal' ) seem to take the higher utility into account but 'authenticate' doesn't. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Customized NotFound-Page
Hi, On Fri, Jan 12, 2007 at 11:24:23AM +0100, Tom Gross wrote: > 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? My guess is either * the viewletManager registration or * the viewlet registration is not correct. I'll be able to tell more from * the page macro template and * the viewletManager + viewlet ZCML Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Security related questions
Hi, is there a way to get all the permissions and roles, the current principal is associated to for a given object? Something like: getAllRoles(context) getAllPermissions(context) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Security related questions
Hi, On Tue, Jan 16, 2007 at 01:15:53PM -0500, Stephan Richter wrote: > On Tuesday 16 January 2007 12:39, FB wrote: > > is there a way to get all the permissions and roles, the current principal > > is associated to for a given object? > > > > Something like: > > > > getAllRoles(context) > > getAllPermissions(context) > > No. You would have to write your own code doing that. Note that it really > depends on the security policy on what roles and permissions are available. My securitypolicy is z.a.securitypolicy :-) . Thank you, Stephan. Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] __setitem__ works, __delitem__ fails on custom site
Hi, On Sun, Jan 21, 2007 at 07:06:36PM -0500, Roy Mathew wrote: > Hi Folks, > > I am trying to create a custom Site object, using the below > declarations; all goes well when addding an object O1 to the QSite, > but when trying to delete object O1, I get: > > ForbiddenAttribute: ('__delitem__', <...QSite object at 0xa61dcd6c>) [snip] > set_schema="zope.app.container.interfaces.IWriteContainer" /> IWriteContainer is not a schema but an api. Use 'interface' instead of 'set_schema'. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Get a site
Hi, On Mon, Jan 22, 2007 at 08:32:21AM +0100, Christian Theune wrote: [snip] > You'd have to open a connection to the database, get the root object and > use that with setSite(). I don't have the complete spelling for that in > my head though. db = zapi.getUtility(IDatabase) conn=db.open() root=conn.root().data['Application'] Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3 PAM or /etc/passwd authentication?
Hi, On Tue, Jan 23, 2007 at 03:28:09PM -0400, Alec Munro wrote: > Hi List, > > I'm wondering if anyone knows of a way to integrate Zope with > /etc/passwd? PAM was suggested, but I don't know too much about that. > I suppose I could probably write my own, but I would prefer to avoid > that if possible. > > Anyone have any experience with this? It seems like it's probably a > fairly common requirement. I had to integrate our local NIS domain into Zope3. So I wrote a PAU-Plugin which receives passwd-style data via XMLRPC (client-script is included). I don't know, how useful this is for your site, because this plugin is rather tightly integrated into my own project (MpgSite). SVN-Url: mpgsite: https://svnserv.cbs.mpg.de/svn/edv/EDV/mpgsite The package name is 'mpgsite.users', the file you're probaly looking for is 'mpgsite/users/passwd.py' . Each PasswdPrincipalInfo object contains one line of the passwd. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] redirect to views dynamically
On Tue, Feb 06, 2007 at 09:01:06PM +0100, Dennis Schulz wrote: > Hello List, > > one question about views: > > I know that is is possible to register a default view for an object. > Is there a way to decide, at runtime, which view to call? > > Maybe a traversal adapter can do this,but is there an easier way? You don't even need a redirect for that: from zope.app import zapi from zope.publisher.browser import BrowserView class DecisionView(BrowserView): def __call__(self): if ...: viewname='index.html' else: viewname='something_else.html' return zapi.getMultiadapter((self.context,self.request),name=viewname)() Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Permission Question
Hi, I've got a container, all of my users have 'zope.ManageContent' permission in. A subobject of the container is sensitive - users must not be able to change this object which means, I've to take away 'zope.ManageContent' permission from all my users (except of one!) whenever context=subobject . I tried using security-annotations which worked fine for single users: ('user-xy','zope.ManageContent',Deny) ('user-owner','zope.ManageContent',Allow) However, this is rather impractical for 1000+ users - so I tried: ('zope.Everybody','zope.ManageContent',Deny) ('user-owner','zope.ManageContent',Allow) - didn't work :-( . The greater picture: I need a "Sticky-Bit"-Container. Users with 'zope.ManageContent' permission should be allowed to create (certain kind of) objects, which will be automatically security (role-)annotated (principal.id,'mpgsite.Owner',Allow). The 'mpgsite.Owner' role implies some permissions - incl. 'zope.ManageContent'. Unfortunately, 'zope.ManageContent' is inherited from the container - granting editing rights to everyone. Did I miss anything or is it impossible to "de-assign" a permission based on roles/groups? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Still a skinning problem
Hi, On Thu, Feb 08, 2007 at 04:54:51PM +0100, Florian Lindner wrote: > Am Mittwoch, 7. Februar 2007 07:50 schrieb Jürgen Kartnaller: > > Florian, > > if you want the url to your current site implement this : > > > > > > class SiteUrlView(object): > > > > def __call__(self): > > return absoluteURL(hooks.getSite(), self.request) > > > > And register a page : > > > > >name="site_url" > >for="*" > >class=".views.SiteUrlView" > >permission="zope.Public" > >/> > > > > Now you can use context/@@site_url anywhere. > > Hi, > this works perfect when using it like: > > home > > but when I try to directly link to a view registered with the object site_url > returns: > > suche Try suche Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permission problem on adapter
Hi, On Sun, Feb 11, 2007 at 01:16:51AM +0100, Dominique Lederer wrote: > hi > > i created a trusted adapter on a content object. > then i created a formlib edit page for the ZMI, to be able to edit the > new attributes on the adapted content object. the adapters interface is > correctly rendered to the form. > > if i try to edit, an unauthorized error is shown, which i also get, when > i register the user as Site Manager via Grant in the ZMI. > The global admin *can* edit the adapters attributes (the one which is > set globally via ZCML). > > i registered the adapter like this: > trusted="true" /> Try to add the attribute 'locate="true"' to the adapter-statement. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Timezones and zope.i18n.locale
Hi, On Thu, Feb 15, 2007 at 02:46:44PM -0800, Jamu Kakar wrote: > Hi, > > I'm looking at integrating zope.i18n.locale into my application (so far > strings are hard-coded in English). Among the first localization tasks > I'm taking on is presenting data in the timezone of the current user. > I've been perusing the code in zope.i18n.locale and I see some mention > of timezones but nothing that would lead me to believe that dates (in > UTC) will be auto-converted to the user's timezone when presented with > formatting methods. AFAIK there's is no easy way of automatically determining a user's timezone. The HTTP-Request contains language preference information only but no timezone preference. However - if you know some clever algorithm which is i.e. able to tell the time zone from the client's IP, you'll have to write an adapter providing zope.interface.common.idatetime.ITZInfo adapted from a IBrowserRequest. Some components (i.e. zc.datetimewidget) will take it into account when interacting with the user. To convert a (tz-aware!) datetime-object to the correct timezone, use a method like that in your view class (not testet): zope.interface.common.idatetime.ITZInfo [...] class MyView(BrowserView): [...] def getLocalTZ(self,mydatetime): tz=ITZInfo(self.request) return mydatetime.astimezone(tz) BTW: Maybe you know that request.locale.dates.getFormatter('dateTime').format(mydatetime) shows a I18Nd and L10Nd datetime according to the user's language preference. If you can read german, you can find more about that @ http://zope3.mpg.de/cgi-bin/twiki/view/Zope/LocaliSation . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope Book: Internationalizing still up to date?
Hi, On Wed, Feb 21, 2007 at 09:02:16PM +0100, Florian Lindner wrote: > Hello, > is the chapter 18: "Internationalizing a package" in Stephans Zope Book > (online version) still up to date or has changed to much so it's not worth > reading anymore? > Any other good sources about i18n? Your eMail's '.de' TLD makes me think http://zope3.mpg.de/i18n might be interesting for you. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Dict Widget
Hi, On Tue, Feb 27, 2007 at 09:24:10PM +0100, David Johnson wrote: > I've seen posts about this but I am confused. Is there a Dict widget? I > tried it and I received IInputWidget errors. Yes, I've written three Dict widgets: 1. A generic Dict widget (*,*) 2. A (Choice,*) Dict widget 3. A Dict widget for multilingual fields (LanguageChoice,*) You might be interested in 1 and 2. The widgets are part of the 'fb' package which is available here: https://fbo.no-ip.org/svn/fbo/fb via svn. The widget itself is part of the subpackage 'fb.fields'. The 'fb' package is dual-licensed under GPL2 and ZPL2.1 so feel free to use whatever you want :-) . Regards, Frank ___ 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
Hi, On Wed, Feb 28, 2007 at 12:57:35PM +, Alek Kowalczyk wrote: > Tom Dossis <[EMAIL PROTECTED]> writes: > > I have another issue with IntIds and NotYet: > I have some BTreeContainer-derieved object which is short-living container. > It is never stored in ZoDB > - it is just a result of some query to external system. > > It worked fine until I enabled IntIds utility. > Now I get NotYet when adding anything to my container - > because IntIds tries to attach Id to it anyway. It tries that, because it's handler is called by the container's __setitem__ method. Just write your own - like that: class MyContainer(BTreeContainer): def __setitem__(self,key,object) object.__parent__=self object.__name__=key self.__data[key]=object def __delitem__(self,key): del self.__data[key] (Not testet!) However, you might not need a BTreeContainer but just a simple BTrees.OOBTree.OOBtree which behaves like a dict but is a btree. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] correct display of Text field in a view
Hi, On Fri, Mar 09, 2007 at 10:06:26AM +0100, Ivan Horvath wrote: > Dear All, > > in my learning application there is a description property > this is declared as Text field in the schema > of course an enter (newline) can be entered in this field, but on the view > page i can see only raw > text > the viewpage class is inherited from DisplayForm > > i've tried already some things: > - modify the description widget data with PlainTextToHTMLRenderer.render(), > but then in the > browser i can see only encoded chars instead of > - i've tried to create a new widget (following Zope3 Developer's Book 15. > chapter), then i > received a textarea html element in the view as well - of course i could > modify the value, of > course i cannot save > > the best would be on the view page a simple html (just texts) taking into > cosideration the new > line chars. > > any idea? how about that: from xml.sax.saxutils import escape class MyView(BrowserView): def __call__(self): self.description=escape(self.context.description).replace("\n","") Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] object hierarchy
On Wed, Mar 14, 2007 at 04:35:53PM +0100, Ivan Horvath wrote: > Dear All, > > i'm really new to zope, but i have learning application, where the > object stru is little bit complex. > > App > | > + Categories >| >+--Categ1 > | > +Type1 > | > +-Article1 > | > +--Article2 > +-Type2 > >+--Categ2 > +- Administration > etc > > i could manage the administration part and in the categories container > i can add new category objects. > but i cannot add into a category object a type container. > i don't really know how to define an interface which is contained and > container too. I'm not sure, if I understand your problem correctly. It's possible to define a set of valid subobjects for each interface: class IType(IContainer): pass class ICategory(IContainer): contains(IType) class ICategoryContainer(IContainer): contains(IType) [...] class Type(BTreeContainer): implements(IType) class Category(BTreeContainer): implements(ICategory) class CategoryContainer(BTreeContainer): implements(ICategoryContainer) There's nothing special about those kind of "constraint-trees". Now I'm guessing: did you forget to specify a and a ZCML-directive per class? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] no Add menu in custom container view
On Fri, Mar 23, 2007 at 03:27:31PM +0100, Ivan Horvath wrote: > Dear All, > > i'm rather new to zope3, thus knowing more and more, but still i have > many problems. > first i displayed the container contents with the very fast solution > containerViews in browser/zcml > it was nice, i have everything what i need, of course i could Add new > object in the container, because i had an Add menu. >title="Type Category" > factory="fa.TypeCategory" > view="addTypeCategory.html" > permission="zope.ManageContent" > /> > > for="zope.app.container.interfaces.IAdding" >name="addTypeCategory.html" >class=".helper.TypeCategoryAddForm" >permission="zope.ManageContent" >/> > > i had to create a customized contents view page, so created a new view > object. it is inhertied from BrowserView. > this is the page declaration in zcml: >for="..interfaces.ITypeCategoryContainer" > name="index.html" > class=".helper.TypeCategoryContainerView" > permission="zope.View" > template="list.pt" > menu="zmi_views" title="List" > /> > > for the display of the contents i use zc.table solution > the problem is here, because the nice Add menu is disappeared. > what can be the problem? You can include the menu for adding subobjects like that: Don't forget to provide an adding-view for your container like this: Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Views for adapted components
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: class ImExPortView(object): def __call__(self): try: export=IImportExport(self.context) except: raise NotImportableException(self.context) [...] Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] view vs page confused
Hi, On Tue, Mar 27, 2007 at 06:03:54PM +0200, Dominique Lederer wrote: [snip] > so if i create a class which inherits from BrowserView, and then register it > via > zcml as browser:page, it becomes adaptes to IBrowserRequest an turns to a > BrowserPage (via the on-the-fly created class)? so inheriting from BrowserPage > instead from BrowserView would make no sense with my example? It doesn't event make sense to inherit from BrowserView because a browser:page-registered view-class is just a mixin. A class like this is enough: class MyView(object): def mySpecialMethod(self): [...] [...] Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] fine grained subscriber
Hi, On Wed, Mar 28, 2007 at 12:16:23PM +0200, Lorenzo Gil Sanchez wrote: [snip] > But I'd like to avoid the if clause inside my subscriber function by > doing something similar to this: > > def intIdRemovedSubscriber(obj, event): > # do some stuff with obj, which is garanteed to provide IMyInterface > > handler=".intIdRemovedSubscriber" > for=".interfaces.IMyInterface > zope.app.intid.interfaces.IIntIdRemovedEvent" > /> [snip] > So the question is: why the intid package is succesful in registering a > subscriber only for ILocation objects and I can't do the same with > IMyInterface objects? > > I want to avoid a lot of calls to my subscriber which will happend > everytime an IntId is removed from *any* object. [snip] You need a dispatcher - a quite common concept in zope3: [events.py, not tested] from zope.event import notify def removeIntId(event): notify(event.object,event) def addIntId(event): notify(event.object,event) [configure.zcml, not tested] [...] [...] Thanks to zope3's component infrastructure, a package (like intid) doesn't have to provide the dispatcher - a different package providing the dispatcher is perfectly fine. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] FieldIndex on boolean field - error
Hi, On Wed, Mar 28, 2007 at 03:55:28PM +, Alek Kowalczyk wrote: > Hi, > I'm trying to index a boolean field of some object, to simplify retrieving all > the objects which have some flag turned on. > > I am adding in proper place the index: > > catalog['anomaly'] = FieldIndex('anomaly', IMyObject) > > But then, when I try to get the objects using the following command, I get an > exception. Is FieldIndex able to index bool field? If not, how to create own > index for doing that? > > anomalies = catalog.searchResults(anomaly=True) [snip] > TypeError: len() of unsized object A fieldindex always requires a lower and an upper boundary, found objects must fit into. Try catalog.searchResults(anomaly=(True,True)) BTW: The error is raised because the fieldindex tries to interpret 'True' as a tuple. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How i can get IRequest
Hi, On Tue, Apr 17, 2007 at 08:55:02PM +0400, Garanin Michael wrote: > Hello! > How i can get IRequest in my event handler (i has only context)? from zope.security.management import getInteraction request = getInteraction().participations[0] Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] session start/end
Hi, On Thu, Apr 19, 2007 at 12:40:54PM +0200, Sascha Ottolski wrote: > Hi, > > reading through zope.app.session, I couldn't find any built-in support > for session_start and session_end events, similar to what existed in > Zope2. Are there any recipies for such a use case? Searching the web > didn't gave me pointers. > > And by the way, is it possible to programmatically access the sessions > of other users? If so, how would one do this? Of course I'm well aware > that security issues might arise. > > The use case for both questions would be to find out if a user > is "online", as an information displayed to other users. There's a persistent object in software space which stores the user session data. However, there's no identification of the user stored in there - except of the login credentials (->only if you use the Session-Credential-Plugin of PAU). You'll have to either assign i.e. the principal id to a user's session data on session creation or be happy with the login name. Example: from zope.app.session.interfaces import ISessionDataContainer from zope.app import zapi def getlogins(): sdc=zapi.getUtility(ISessionDataContainer) sessions=sdc.values() for session in sessions: if 'zope.app.authentication.browserplugins' in session: yield session['zope.app.authentication.browserplugins'].getLogin() (untestet, dangerous, no warranty, ...) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users