Re: [Zope3-Users] __init__ method never called?
Hi, both Resource and BrowserView have a common parent class, viz Location, whose parent class is object. object | | Location / \ / \ / \ BrowserView Resource \/ \ / \/ FileResource As there are no calls to super() in any of the definitions of BrowserView, Reource, FileResource or Location, only the __init__ method of BrowserView would appear to be called because attribute lookup proceeds through the parent classes in the order they are provided in the definition. This can be practically tested by inserting a NotImplementedError into to the definition of Resource.__init__. I'm pretty certain that that method is never called, unless perhaps somewhere else in zope there is another class that inherits from it first. Cheers, John. --- Stephan Richter <[EMAIL PROTECTED]> wrote: > On Tuesday 19 September 2006 03:47, FB wrote: > > (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. > > >>> class First(object): > ... def __init__(self): > ... print 'init 1-before' > ... super(First, self).__init__() > ... print 'init 1-after' > ... > >>> class Second(object): > ... def __init__(self): > ... print 'init 2-before' > ... super(Second, self).__init__() > ... print 'init 2-after' > ... > >>> 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> > >>> > > Regards, > Stephan > -- > Stephan Richter > CBU Physics & Chemistry (B.S.) / Tufts Physics > (Ph.D. student) > Web2k - Web Software Design, Development and > Training > ___ > Zope3-users mailing list > Zope3-users@zope.org > http://mail.zope.org/mailman/listinfo/zope3-users > ___ Yahoo! Photos NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] __init__ method never called?
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. does anyone know if that Resource.__init__ method is used by anything else? Thanks, John ___ All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine http://uk.docs.yahoo.com/nowyoucan.html ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Interface or adapter for AddMenuItems
Hi, I have a content container object and I was wondering what is the easiest/best way to access the list of allowed content types which may be added to this container. Is there an interface to which I can adapt my object, or a menu service/utility? I looked in the page template code template.pt, but it looks as if the items in the add menu come in as some kind of html text string. Any help gratefully received, Thanks, John ___ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Access request object from content_factory
--- Rupert Redington <[EMAIL PROTECTED]> wrote: > I realise that I shouldn't use zapi anymore... apart Good gracious! No zapi? How did I miss that? Where do I get my utilities, parents, roots, adapters from now? John. (dazed and confused) ___ Inbox full of spam? Get leading spam protection and 1GB storage with All New Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Access request object from content_factory
Well, I always like to do things the way the experts recommend :) Are there any suggestions for this use case?: I have a content class, which consists of 2 attributes: 1. a user comment 2. the name of the logged in user So far, I have been using the browser:addform directive to add instances, which generates all my views for me. (I love this and do not want to lose it). I have read about annotations and the DublinCore and I think I can go digging in __annotations__, if I make my class IAttributeAnnotable and get the logged in user name. The thing is, in this use case, the logged-in-user attribute is not metadata, it is a fundamental component of this particular content object. So, my question boils down to: what is the recommended way to get at the request object in a content factory when using browser:addform. The reason I think this matters is that there are so many adapters and utilities that need a request object, it seems unnecessary to deprive a content factory of the use of them, when the developer chooses to take advantage of browser:addform. Best wishes, John --- Philipp von Weitershausen <[EMAIL PROTECTED]> wrote: > Marco Mariani wrote: > > Rupert Redington wrote: > >> from zope.security.management import > getInteraction > >> > >> request = getInteraction().participations[0] > >> > >> Why this works is outlined (IIRC) in > zope/app/securitypolicy/zopepolicy.txt. > >> > >> There may well be better ways to fish for the > request than this... any > >> offerings? > >> > > In my understanding, if you need to look for the > request inside a > > content object, you're doing something that should > be done in another > > place, be it a view or an adapter. > > Indeed. > > > Of course, I've been wrong before :-] > > Not this time :). > > The hack displayed above (going thru the security > interaction) should > not be considered a standard procedure for getting > at the request in > places where you don't have it. Content objects are > dull. They do > nothing. Other stuff does things *to* them. Mats' > solution is the better > one. > > Philipp > > ___ > Zope3-users mailing list > Zope3-users@zope.org > http://mail.zope.org/mailman/listinfo/zope3-users > ___ Inbox full of spam? Get leading spam protection and 1GB storage with All New Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Access request object from content_factory
Hi, I am trying to add some request related data into a content object (eg authenticated user etc). The content is being added using a normal addform/content_factory zcml approach. The class __init__ method does not receive any arguments, and the context/request pair are only available inside of views. So I am stumped. How do I get at the request object? A utility? An adaptor? Thanks, John Try the all-new Yahoo! Mail . "The New Version is radically easier to use" The Wall Street Journal___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Add and Edit form
I am a little unclear into which object I should add the nextURL method.In myclass/browser/configure.zcml I have addMenuItem and addForm directives. I have tried adding the nextURL method to the class specified in the 'class' parameter of the addForm directive. That does not work.Stephan replied that the zope.app.form classes is where to override the nextURL method, but where do I fit a zope.app.form instance into my configuration?Thanks,JohnCliff Ford <[EMAIL PROTECTED]> wrote: This is an example mextURL function that I used to add a folder containing a page, and then go to the folder. Going to the page is just an addition to the last line.HTHCliff def nextURL(self): """ This function is called for redirection after folder creation. We can use it to fill out metadata collected from a custom add form. """ Yahoo! Cars NEW - sell your car and browse thousands of new and used cars online search now ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Add and Edit form
Problem: Would like to add an object to a container and jump to the edit screen for the newly created object immediately. Currently, adding an object to a container takes me to the container's content list. When there are 10 or 15 people all adding objects, finding the one I entered in order to edit it is a usability issue. Solutions: a) there is something already in zope3 that I don't know about :) b) create an "Add and Edit" button to go beside the "Refresh" and "Add" buttons in the standard template and create some handler for this. Thanks in advance for any pointers. John Smith Yahoo! Cars NEW - sell your car and browse thousands of new and used cars online search now ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Managing Principals
Dear Zope Users, I am trying to create a site where the site manager can a) create/delete principals ttw b) assign/edit roles for a principal ttw. Can anyone advise how to go about this. I'm using Zope3.10 and I presume that I want some kind of variant on the zope.app.authentication.principalfolder ideas. Has someone already solved this problem? Best wishes, John ___ NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] macros from ZPT
Dear All, Does anyone know if it is possible to access macros defined in a TTW ZPT from a file-system based view class? In a TTW folder, I have added a ZPT and edited it to contain a page macro. Then, in the file system, I put a getMacro method into the view class for my object. Next, from the file system page template which renders the view for the object, I seem unable to pick up the TTW macro. I have tried: metal:use-macro="view/getMacro/macros/page", and a range of variants with no success. I have read some posts that hint that perhaps I am trying to do something not yet available within Z3. I know that my view class getMacro method is returning a relevant object as my debug output shows that I can access the 'macros' attribute ok. Thanks in advance for help, john ___ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Access attributes of content object from view
Dear All, I have a containerish content object, subclassed from BTreeContainer. I have a view class which lists some of the contents. The view class receives a security proxied version of the content object but when I try len(self.context.values()) if get Forbidden Attribute : ('__len__', ) I have tried altering the zcml content/require permissions but they are all set for "zope.View", including the IReadContainer interface. Is it to do with the fact that the object is subclassed from BTreeContainer? Any pointers gratefully received, Thanks, John ___ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Get to ZODB root from global utility
Dear Jim, > Did you try IBuddy? ;) It was IBuddy that got me into this ! (mutters darkly under breath) My utility bears a strong resemblance to IPostalLookup :) Anyhow, I am pleased to report success, and thank you for your pointers. The lines below are for the benefit of google anyone else who has the same problem. 0. How to access the Zope3 ZODB application root and programmatically add content objects. 1. Upgrade to Zope 3.1.0 2. from ZODB.interfaces import IDatabase 3. db = zapi.getUtility(IDatabase) 4. conn = db.open() 5. root = conn.root().data['Application'] 6. root['newobject']= or navigate to where you need to go 7. conn.getTransaction.commit() and tidy up. John ___ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Get to ZODB root from global utility
Dear Jim, I was unable to import IDatabase from ZODB.interfaces, although I could import IDataManager and IConnection. However, when I tried: root = zapi.getUtility(IDataManager) I got a componentlookuperror. (The same error happens with IConnection). Any thoughts? Thanks for your help, John --- Jim Fulton <[EMAIL PROTECTED]> wrote: > John Smith wrote: > > Hi, > > > > Does anyone know if there any way to get to the > main > > ZODB root of the site other than using > > zope.app.zapi.getRoot(someObject)? > > > > Here is the background. I want to programatically > > create new folders underneath the Zope root, > according > > to some external source which my zope instance > polls > > periodically. > > > > I have made a global utility what spawns a worker > > thread which creates the folder objects. My > problem is > > I don't seem to be able to work out how to get > hold of > > the Zope root as I have not get any context. > > Each database defined in zope.conf is registered as > a ZODB.interfaces.IDatabase with the name given in > zope.conf. If you you have only one database and it > doesn't have a name, then you should be able to look > up the utility without supplying a name. > > Jim > > -- > Jim Fulton mailto:[EMAIL PROTECTED] > Python Powered! > CTO (540) 361-1714 > http://www.python.org > Zope Corporation http://www.zope.com > http://www.zope.org > ___ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Get to ZODB root from global utility
Hi, Does anyone know if there any way to get to the main ZODB root of the site other than using zope.app.zapi.getRoot(someObject)? Here is the background. I want to programatically create new folders underneath the Zope root, according to some external source which my zope instance polls periodically. I have made a global utility what spawns a worker thread which creates the folder objects. My problem is I don't seem to be able to work out how to get hold of the Zope root as I have not get any context. Thanks, John ___ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Zope3 broke when renaming folder
Dear Zope users, Does anyone have a map as to where Zope3 stores its data inside the ZODB? the application data is in .root()['Application'] and I can see my folders there. But what about the registration processes: is there some mapping somewhere inside the ZODB that I can edit to get my zope to restart? What happened was I renamed a folder and zope3 had an error. Renaming the folder to its previous value in ZODB does not seem to have any effect, and the system refuses to let me do anything: undo, delete etc. At this point, my only option, is to delete Data.fs and start again, but this seems a bit nuclear, for what must surely be a bit of ZODB editing, if I but knew where to look. Thanks, John ___ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Renaming folder causes NotFoundError
At the highest level of my content pages (ie the blue pages in the zmi) i had a folder called 'myfolder'. This folder contained my test objects ( the Car and Journey example from my previous post). The data was trivial and no loss to anyone. I'm still experimenting. Anyhow, I tried to rename the folder to something more descriptive, and Zope3 keeps coming up with the "There has been a system error" page, and on the terminal it say s NotFoundError, 'myfolder'. I have gone into the ZODB directly, and the root['Application'] item contains the folder and its contents, but with the new name 'MileageTracker'. Firstly, I was a bit surprised that ZopeX3-3.0.0 did this on a simple rename, although possibly it has something to do with the contents of 'myfolder' which where my own attempts at creating containers. But now I'm intrigued because somewhere inside my ZODB the system has remembered the old folder name even the root['Application'] mapping object only seems to know the object by its new name. I have tried renaming the object back to its original name, and committing the transaction, but that does not work, an incremented integer seems to be added to the name. As I said, I'm not bothered about the data itself, it is just that I would like to use Zope3 in a production environment and I'd like to know how to recover from this type of thing. I've tried debugging the source by putting in print statements and as best I can tell, the magic is somewhere around line 604 in zope.app.registration.registration.py where "Adapters" is the supplied name and a serviceregistration object is createed whose componentPath attributes is 'myfolder'. From where in the ZODB is it reading this value! Any help gratefully received, John ___ Yahoo! Model Search 2005 - Find the next catwalk superstars - http://uk.news.yahoo.com/hot/model-search/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] configure.zcml entries for using adapters.
I have a content component called 'journey' which provides three attributes: journey_description, journey_date, and distance_travelled. These 'journey' objects live in a container called 'car'. A car has attributes like owner, registration etc. So far, Everything is fine. I thought I would try to use adapters to extend the functionality of a 'car' object so that in the zmi_views, I could have a 'totals' page, showing the sum of the distance_travelled attributes of all the car's journey objects. I created an interface for the adapter, IDistanceTotal which describes one method, getTotalDistance. I created and adapter class, CarTotalDistanceAdapter. I updated configure.zcml like this: I tested the correct operation of the adapter in accordance with: Zope 3 Developer's Handbook,p142 and also with Web Component Development with Zope 3, page 149. The adapter was recognized, the getTotalDistance method appeared as an attribute of the Car object and valid results appeared for the distance travelled. I then created a nice page template which contains this snippet: where context is the Car object. Now, here is my problem: no matter what I do in the configure.zcml file, I cannot seem to get the context object to pick up the getTotalDistance method from the adapter. Depending on the security/permissions settings I either see: forbidden attribute or not found errors. I have tried studying the code of the zwiki product but to no avail. Am I right in thinking that my problems are related to the configure.zcml file? Any pointers gratefully received. I can get the ISized examples from the books to work ok. Thanks to all. John ___ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] browser:form
Hi Everyone, Can anyone give me a few pointers how to use a schema to auto generate a form that I can use in a view of a content object? The content object is a sort of "vehicle manager" which has an interface IVehicleManager. the Vehicle stores things in the ZODB like the dsn for an SQL database and other configuration stuff. There is then a schema, IVehicle, which lists such things as colour, reqistration, make, model, year etc, and these details I want to store in the SQL database. Up to now, I have been using a hand coded ZPT as a view object of the VehicleManager to capture Vehicle data. Surely there is some way to use the IVehicle schema to auto-generate the form, for use outside of the ZMI. Just a few pointers would help. For example, does the browser:form directive return a whole page, or do I somehow refer to the browser:form object from a separate browser:page built from .pt file? Thanks for any help, John ___ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] HTTP Post Request Handling
Dear All, I hope I have the right mailing list. Perhaps someone can help me with a fairly basic question. When I used Zope 2, I used the following idiom for form submission. Send http POST to Script(Python) or External Method, which would then return a ZPT like this: return context.myZPT(arg1=xyz, arg2=abc, etcetera). In the ZPT, I could then access arg1, arg2 via the 'options' TAL name. Now, I am getting along OK with Zope3. I understand that the basic TAL namespaces available in a ZPT are view, request and context. As far as I can tell from documentation and examples, POST requests are handled by the self.request.response.redirect idiom. My problem with this method is that it causes the instantiation of a new view component, so I cannot hold state with the 'view'. I would be very grateful if anyone could tell me how I can pass arguments to the rendered page template. I do not wish to set attributes on the content/context object as the form values from the POST request are specific to the request. so I cannot hold state with the 'context'. I don't want to use cookies as the form has to work in environments where cookies are disabled. I tried searching the interface specification for 'request' to see if there was an analogue of the Zope2 request.setAttribute function, but could not find one. Any help greatly appreciated, thanks, John. ___ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users