Re: [Zope-dev] Re: [Zope3-dev] Need help with http://dev.zope.org/Subversion
On Sun, Apr 25, 2004 at 12:48:30PM -0400, Fred Drake wrote: > On Sunday 25 April 2004 12:29 pm, Jim Fulton wrote: > >cvs co svn+ssh://svn.zope.org/repos/Zope3/trunk Zope3 > > That should be: > > svn co svn+ssh://svn.zope.org/repos/Zope3/trunk Zope3 > > >cvs co http://svn.zope.org/repos/Zope3/trunk Zope3 > > and this would be: > > svn co http://svn.zope.org/repos/Zope3/trunk Zope3 Does that mean, that Zope will use svn with cleartext passowords for write access? Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Product directory?
On Tue, Mar 09, 2004 at 01:58:17PM -0500, Ian Beatty wrote: > Greetings again. > > This has to be an easy one. > > >From within my Python-based product's code, how do I get access to the > product's directory on the filesystem? os.getcwd() seems to provide the > working directory of the shell used to launch Zope, at least when running in > debug mode. Try os.path.dirname(mymodule.__file__)? Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __before_publishing_traverse__problem
On Fri, Nov 21, 2003 at 11:41:53AM -0500, Casey Duncan wrote: > On Fri, 21 Nov 2003 17:33:43 +0100 > lukasz <[EMAIL PROTECTED]> wrote: > > > I have a problem.When I import my plone site from one server to other I > > got : > > > > AttributeError: > > __before_publishing_traverse__ > > > > What should I do with that? > > Post it to the *Plone* mailing list? And when you are at it, post the whole stack trace (to the plone list), because the error as such doesn't say anything useful ;) Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope - Document Management Integration
Am Mittwoch, 8. Januar 2003 02:51 schrieb Sameer Maggon: > Hi all, > > We have our own proprietary Document Management Product. Lot of our > clients have their valuable data (images, web-pages, other documents) > in our repository (powered by our DM product). Now is there a way we > can incorporate CMS facilities using Zope where the users can make > web-sites using the content from our DMS. > If anybody has some idea, please discuss it. I can mail other > relavant details. Well, that depends how you can access the DMS data. (proprietary protocol, xml-rpc, corba, etc.) Depending upon intend you can then build "proxy" objects for Zope. The question remains why you want to do this. Zope seems quite capable to do custom document management (when setup rightly). And if you go the proprietary way with the document management, you should be also capable to do some proprietary CMS solution :) Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] allowable object ids
Am Sam, 2002-11-23 um 18.30 schrieb Jamie Heilman: > Turns out you can create objects with an id of . or .. although you Well, you can access these properties/objects from DTML/Python. Not from ZPublisher (the URL->Object Request Broker). > can't access them. (which is to say I couldn't figure out how, though > I didn't try ZServer standalone and I suppose apache might be doing > something to the URI) You can't create objects with ids containing + > or % or a host of other characters though (and btw the error message > you get when you try is horrid, those characters are not illegal in > URLs, illegal in the zope object model perhaps, but not URLs). I'm > currious, why aren't arbitrary characters allowed in object ids? Well, because of the implementation details, it is not possible to allow certain ids (things that start with '_' or 'aq_', etc.). Why % is not allowed I can only guess at, but I'd assume that the authors tried to get "sane" ids. It's a bit like the Unix Filesystem. By definition it allows all characters except '\0' and '/'. Still it's rather stupid and inconvienent to use exotic characters. By the way, you can look Zope/lib/python/OFS/ObjectManager.py:checkValidId (line 49) to see what is allowed and what not. Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __before_publishing_traverse__calls RESPONSE.redirect(): is there another way to change the browser URL?
Am Sam, 2002-09-28 um 05.35 schrieb Craeg K Strong: > Sorry for the non-sequitur.. I do not really know if Zope uses the urllib2 > machinery or not. Somewhere, however, there must be some code that catches > > raise 'Redirect', myurl Well, it's just send a response to the browser. You thing it's like this: client -> server obj -> server obj2 -> client In fact it's: client -> server obj -> client client -> server obj2 -> client > > and does the appropriate thing (creates a new request, etc.). > > My "find-grep" caught class HTTPRedirectHandler(BaseHandler): (line 427 of > urllib2.py) > > But I have not looked into it enough to understand whether it is what > I am guessing it is, and-- even if so-- whether Zope uses it or not. Nope it is not what you guess. > > in any event, there are other, better solutions on the table, so at this point > it is no longer important... > > > > >>Today, that code creates a new REQUEST object, throwing away the old request. > >>I could cause it to insert some value that I would then test for, > >>to distinguish the two cases. > > > > REQUEST.redirect sends a status code to the browser which then requests > > the new URL by itself, ... > > > >>That would be the king of all hacks, but it might work :-} > > > > Probably not. The only thing you can do with redirect is to urlencode > > your parameters, ... > > You're probably right. The browser is getting back a status code in the HTTP > header that makes it generate a new request. The question I had was: would > there be a way to stuff something in the HTTP header that the browser would > somehow copy over to the new HTTP header it sends back in response to the > redirect status code...? Cookies (if enabled). GET style parameters appended to the URL. Problem with GET and actions is, that the HTTP spec allow the client to request it more than once. That's way at least netscape asks before rePOSTing an URL while it reloads a GET URL without user interference. Actually the HTTP spec allow an browser to get an url repeatedly for any reasons. This is the HUGE semantic difference between GET/POST. (And not that the parameters are passed via the url or stdin, ...) Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __before_publishing_traverse__ callsRESPONSE.redirect(): is there another way to change the browser URL?
Am Fre, 2002-09-27 um 20.58 schrieb Craeg K Strong: > Thanks for the advice! > > Unfortunately, I don't know how to do what you suggest. > > I believe that a redirect always causes a GET, rather than a POST, no? > > Also, hidden form fields are filled in on the original request, but the redirect > flushes the request. All of my fields are gone! :-( > > Perhaps I could do something really nasty and override the Python method > in urllib2 that handles HTTP redirects? What to hell does urllib2 have to do with Zope? > > Today, that code creates a new REQUEST object, throwing away the old request. > I could cause it to insert some value that I would then test for, > to distinguish the two cases. REQUEST.redirect sends a status code to the browser which then requests the new URL by itself, ... > > That would be the king of all hacks, but it might work :-} Probably not. The only thing you can do with redirect is to urlencode your parameters, ... Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Unicode treatment in 2.6b1 [TRACEBACK]
Am Fre, 2002-09-27 um 17.17 schrieb Florent Guillaume: > On Fri, 2002-09-27 at 16:42, Andreas Kostyrka wrote: > > I've traced back the source of my UTF-8 + plain string problem. > > My python script calls manage_changeProperties like this: > > context.manage_changeProperties({'standorte':standorte}) > > You should use > > context.manage_changeProperties(standorte=standorte) > > otherwise manage_changeProperties thinks (stupidly) that the mapping > that was passed is a REQUEST, and tries to return the management page, > whose rendering sets the UTF-8 header. I thought manage_editProperties is here to deal with the ZMI? > > There is a lot of braindeadness like that in this old code (abuse of > REQUEST), but we have to deal with it. :-( Well, either one has two APIs (for web and internal use) or we will have to live with things like this. :( [I do not see a way to differ between this two, as most internal use is triggered by some web request, ...] Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Unicode treatment in 2.6b1 [TRACEBACK]
Hi! I've traced back the source of my UTF-8 + plain string problem. My python script calls manage_changeProperties like this: request = container.REQUEST RESPONSE = request.RESPONSE standorte=request['standorte'].replace(', ',',') context.manage_changeProperties({'standorte':standorte}) return context.index_html(context,request) Now if I comment out the manage_changeProperties, it works ok, but of course does not change the property. Andreas Following are the exact tracebacks I've generated: Am Fre, 2002-09-27 um 12.54 schrieb Andreas Kostyrka: > Am Fre, 2002-09-27 um 11.30 schrieb Toby Dickenson: > > On Friday 27 Sep 2002 10:16 am, Andreas Kostyrka wrote: > > > > > Now in some cases ZPublisher adds the UTF-8 content-type > > > > To a response header? I fairly sure ZPublisher never does that. > Well, someone does. I do not :) > > > > Perhaps you could add some debugging hooks to RESPONSE.setHeader to see who > > is? > I'll look into that. Well, I've added a traceback.print_stack like this: Index: HTTPResponse.py === RCS file: /cvs-repository/Zope/lib/python/ZPublisher/HTTPResponse.py,v retrieving revision 1.70 diff -u -u -r1.70 HTTPResponse.py --- HTTPResponse.py 24 Sep 2002 22:13:26 - 1.70 +++ HTTPResponse.py 27 Sep 2002 14:37:49 - @@ -17,6 +17,7 @@ import types, os, sys, re import zlib, struct +import traceback from string import translate, maketrans from types import StringType, InstanceType, LongType, UnicodeType from BaseResponse import BaseResponse @@ -240,6 +241,8 @@ return name = literal and name or key self.headers[name] = value + if name.upper()=="CONTENT-TYPE" and value.find("UTF")<>-1: + traceback.print_stack() def addHeader(self, name, value): '''\ It produced: File "/home/andreas/Zope/ZServer/PubCore/ZServerPublisher.py", line 23, in __init__ response=response) File "/home/andreas/Zope/lib/python/ZPublisher/Publish.py", line 150, in publish_module response = publish(request, module_name, after_list, debug=debug) File "/home/andreas/Zope/lib/python/ZPublisher/Publish.py", line 98, in publish request, bind=1) File "/home/andreas/Zope/lib/python/ZPublisher/mapply.py", line 88, in mapply if debug is not None: return debug(object,args,context) File "/home/andreas/Zope/lib/python/ZPublisher/Publish.py", line 39, in call_object result=apply(object,args) # Type s to step into published object. File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 252, in __call__ return self._bindAndExec(args, kw, None) File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 283, in _bindAndExec return self._exec(bound_data, args, kw) File "/home/andreas/Zope/lib/python/Products/PythonScripts/PythonScript.py", line 315, in _exec result = apply(f, args, kw) File "Script (Python)", line 9, in setStandorte File "/home/andreas/Zope/lib/python/OFS/PropertyManager.py", line 289, in manage_changeProperties return self.manage_propertiesForm(self,REQUEST,manage_tabs_message=message) File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 252, in __call__ return self._bindAndExec(args, kw, None) File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 283, in _bindAndExec return self._exec(bound_data, args, kw) File "/home/andreas/Zope/lib/python/App/special_dtml.py", line 174, in _exec try: result = render_blocks(self._v_blocks, ns) File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 266, in __render_with_namespace__ return self._bindAndExec((), namevals, namespace) File "/home/andreas/Zope/lib/python/Shared/DC/Scripts/Bindings.py", line 283, in _bindAndExec return self._exec(bound_data, args, kw) File "/home/andreas/Zope/lib/python/App/special_dtml.py", line 174, in _exec try: result = render_blocks(self._v_blocks, ns) File "/home/andreas/Zope/lib/python/DocumentTemplate/DT_Util.py", line 201, in eval return eval(code, d) File "", line 0, in ? File "/home/andreas/Zope/lib/python/ZPublisher/HTTPResponse.py", line 245, in setHeader traceback.print_stack() The related PythonScript does a return context.index_html(context,request) at this place. Further investigation asserts that the value returned from this expression is a plain text with 8bit characters in it. In fact adding u'' to it breaks of this. Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Unicode treatment in 2.6b1
Am Fre, 2002-09-27 um 11.30 schrieb Toby Dickenson: > On Friday 27 Sep 2002 10:16 am, Andreas Kostyrka wrote: > > > Now in some cases ZPublisher adds the UTF-8 content-type > > To a response header? I fairly sure ZPublisher never does that. Well, someone does. I do not :) > > Perhaps you could add some debugging hooks to RESPONSE.setHeader to see who > is? I'll look into that. Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Unicode treatment in 2.6b1
Am Don, 2002-09-26 um 23.58 schrieb Florent Guillaume: > Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > > So how are these Unicode changes supposed to work? Are non-ascii > > characters forbidden now? And how do I get UTF-8 text into Zope? > > If all your code outputs is plain python strings, ZPublisher passes them > as-is to the client. Well, my index_html produces a plain string with 8bit characters. (I've verified this by trying to add u'' to it, and got an exception) Now in some cases ZPublisher adds the UTF-8 content-type and some it don't. Directly calling (via browser) index_html does not mark the content as UTF-8. return context.index_html(context,request) marks the content up as UTF-8 although index_html does return a plain old string. And it does nothing to recode the string in UTF-8, ... Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
RE: [Zope-dev] [ZOPE 2.6 B1] Unicode/locale problems withOFS/dtml/properties.dtml
Am Don, 2002-09-26 um 18.47 schrieb Arnar Lundesgaard: > > what do you mean by "inserted into the form"? > > Put there by the dtml-method in a dtml-var statement. I can second this. With CVS-Zope (did the last cvs up this moment) I'm getting a very curios thing: Displaying .../index_html is ok. But return context.index_html(context,request) creates broken characters instead is isolatin1 Umlaute. In my case (Konqueror on Linux) it seems that the text/html;charset=UTF-8 breaks the page because the byte values are correct for the "Umlaute". This is further confirmed by the fact that forcing Konq to display iso8859-1 fixes the display. So how are these Unicode changes supposed to work? Are non-ascii characters forbidden now? And how do I get UTF-8 text into Zope? While I'm quite sure that this will help Zope in the Asiatic region, it seems quite inconvienent for isolatin1 world :( > > > That the response contains a single byte where you properties > > contain character whose unicode value is greater than 127 ? > > Yes > > > how have you checked this? if so, thats a bug. > > In a Hex editor... > > The character 'æ' for instance is inserted as '0xE6' in the > returned HTML. The same here with Umlaute, ... I've used wget and less ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mit, 2002-09-25 um 12.44 schrieb Lennart Regebro: > From: "Andreas Kostyrka" <[EMAIL PROTECTED]> > To: "Lennart Regebro" <[EMAIL PROTECTED]> > > > You shouldn't, really. > > > Why not? > > Because that's not how it's supposed to work. You can override __getattr__ > to have special magick attributes. Acquisition is not a special magick > attribute. __getattr__ is only called when an attribute aren't found in a > "normal" way, and in the context of Zope, Acquicistion would be regarded as > normal. :-) But my attributes are not normal. So I should generate them by __getattr__. Only by noticing that I could get the same effect by putting my attribute source in front of my object in the acquisition chain. The question is still, how does one a __getattr__ that needs (as a client) acquisition to calculate the attribute. (Basically __of__ works only if I do not need to know the attribute name and do not mind a changed acquisition chain, __getattr__ works only if I do not need Acquisition, ...) > > Done. Only thing I've noticed that the Catalog shows this "additional" > > path elements, ... > > I guess that depends on when you patch in the extra object in the > acquisition. If you do it in __of__() then I guess it's visible all the Well, where else can I patch it in? Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mit, 2002-09-25 um 10.06 schrieb Lennart Regebro: > From: "Andreas Kostyrka" <[EMAIL PROTECTED]> > > And how do I return an attribute that is acquired (but not down th main > > acquisition path, but on a side line?) > > You shouldn't, really. Why not? > > > I assume that I could probably play some silly games with __of__ to make > > my additional Acquisition objects to come just before my object in the > > acquisition path, ... > > Yup, much better idea. Done. Only thing I've noticed that the Catalog shows this "additional" path elements, ... See also www.zope.org/Members/yacc/FlexData ;), I've left the old __getattr__ hack commented in the source, ... Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] how to change to another authenticated userprogrammatically?
Am Mit, 2002-09-25 um 09.27 schrieb Chris Withers: > Craeg K Strong wrote: > > > > I am working on an application where users register themselves. That is, > > there will be a registrar username and password that is sent out to all > > prospective users via email. > > > > The only thing the registrar can do is add a user. > > Not sure why you can't just mail out actual user details if the first and only > thing a registrar does is register themselves... Or even better: Do not authenticate the users, instead provide a method that has the Proxy rules set, and check the password inside the method. Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Die, 2002-09-24 um 21.32 schrieb Dieter Maurer: > Andreas Kostyrka writes: > > ... > > > __of__ is non-intuitive but it can work. > > So how do I call it? > > return myitem.__of__(self) > > Doesn't make sense, as self is not wrapped and as such DOES not contain > > any knowledge how it was accessed, ... > Acquisition lookup is implemented by a recursive function: > > While you are right that "self" does not know how it was accessed, > the recursive lookup function does (on its runtime stack). And how do I return an attribute that is acquired (but not down th main acquisition path, but on a side line?) I assume that I could probably play some silly games with __of__ to make my additional Acquisition objects to come just before my object in the acquisition path, ... But still it seems to me, it could be nice if __getattr__ would be called on an explicit wrapper of self, instead of the direct pure self. Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] DevC++ from sourceforge to build Zope on win32/linux
Am Mit, 2002-09-25 um 01.00 schrieb James Johnson: > How would a project sound. I'm thinking about trying to put it together > using ming32 with devC++. Does it sound possible, or would I be wasting my > time. I'm taking a C language class and I want to play around with the Zope > source. The link to devC++ follows Well, while Zope comes with some C sources (42436 lines to be exact) but it's still a Python project at heart (63738 lines). I'm not sure what exactly is the topic of your C language class, but Zope as such is not the most trivial project to study. Especially as most of the C language modules are optimizations of Python modules that gave most Python developers already headaches when they where Python modules, ... (LOCs from CVS checkout version, there are also 13788 lines of DTML, > http://sourceforge.net/projects/dev-cpp/ As far as I can see this is just an IDE for gcc/w32. What does this have to do with Zope? Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] how to change to another authenticated userprogrammatically?
Am Die, 2002-09-24 um 19.41 schrieb Craeg K Strong: > Alternative number two is to force the user to reauthenticate-- somehow get the > browser to popup a login screen where the user can type in the new username and > password. This might be easier, b/c it is simply a matter of sending > back the appropriate HTTP Header and status codes, right? Create an object/page that is viewable by all users except the registrar user. Redirect the user to it. Andreas -- Andreas Kostyrka <[EMAIL PROTECTED]> ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] small patch to cDocumentTemplate.c to ease debugging
Hi! As pDocumentTemplate.py is out-of-order at the moment, here is a small patch to make cDocumentTemplate show more attributes (to help debugging). Andreas Index: lib/python/DocumentTemplate/cDocumentTemplate.c === RCS file: /cvs-repository/Zope/lib/python/DocumentTemplate/cDocumentTemplate.c,v retrieving revision 1.48 diff -u -u -r1.48 cDocumentTemplate.c --- lib/python/DocumentTemplate/cDocumentTemplate.c 5 Aug 2002 20:51:14 - 1.48 +++ lib/python/DocumentTemplate/cDocumentTemplate.c 23 Sep 2002 18:41:55 - @@ -447,6 +447,11 @@ { if (strcmp(PyString_AsString(name),"level")==0) return PyInt_FromLong(self->level); + if (strcmp(PyString_AsString(name),"dicts")==0) +{ + Py_INCREF(self->data); + return self->data; + } } if (self->dict) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 18.29 schrieb Florent Guillaume: > Andreas Kostyrka <[EMAIL PROTECTED]> wrote: > > Am Mon, 2002-09-23 um 11.12 schrieb Florent Guillaume: > > > Anoter way to do that is to play games with __of__. > > > Look at the implementation of the skins tool in CMF for an example. > > Doesn't help, as I do NOT know my container :( > > Yes it does. > __of__ is non-intuitive but it can work. So how do I call it? return myitem.__of__(self) Doesn't make sense, as self is not wrapped and as such DOES not contain any knowledge how it was accessed, ... /site1/shared/a/b/c/x /site2/shared/a/b/c/x might be quite different things? My problem especially is not generating a wrapper, but to acquire some object from up my acquisition chain, ... > > > Basically __getattr__ when called does not know it's containment > > anymore. :( > > You didn't look a the code I pointed to you. Look at CMFCore/Skinnable > to be precise (not everything is to be used of course). > > * In __of__ you store the parent in a volatile attribute, > * in __getattr__ you lookup the volatile attribute > > This works as long as your object is not used in several different > acquisition contexts. But exactly THIS I want to support. How should I know if the object will not be used sometime in the future with different contexts. How can I know that my content objects will not be recycled in a second Virtual Host? etc. Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 19.28 schrieb Florent Guillaume: > But it's not necessarily a problem if you take care to use aq_inner. > That depends on the use you have for the parent, really. General Zope site? Basically I want this capability to be incorporated in some general building class, ... So I cannot know what my users (that might be website developers) will be doing with the gadget, right? Actually I could be in the unhappy situation to be forced to share parts of websites I currently develop with newly developed ones, ... But __of__ is still a really nice trick :) Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 11.12 schrieb Florent Guillaume: > Anoter way to do that is to play games with __of__. > Look at the implementation of the skins tool in CMF for an example. Doesn't help, as I do NOT know my container :( Basically __getattr__ when called does not know it's containment anymore. :( Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 13.10 schrieb Chris Withers: > Andreas Kostyrka wrote: > > The problem is, that __getattr__ does not have access to the acquisition > > chain. > > I think it does, but I may be corrected. Well, it's definitly not wrapped. I know because I had to work around that. And it's definitly quite sick how I do this :) > > Some things to check for: > > 1. Do the classes of you object (and containing objects) inherit for > Acquisition.Implicit? I inherit from OFS.Folder.Folder, this should be enough, wouldn't it? Especially Acquisition works quite well in all other methods, just not __getattr__. > > 2. Are you getting hold of the object in such a way that it is acquisition wrapped? Well, I'm not getting hold of anything. It's more like Zope is getting hold of my objects to publish. As I've solved my problem (well, it works, I understand the problem, and I know the correct solution, but I shying away of hacking Acquisition. It's easier (for me) to get my wrapper from the Python frame stack than to patch Acquisition.c.) Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 10.35 schrieb Lennart Regebro: > From: "Andreas Kostyrka" <[EMAIL PROTECTED]> > > Nope it is not. In a normal method you can access something acquired > > like this: > > self.acquired_value. > > I often do just that. :-) I'm not 100% sure what you need to include for > that to work, but I would expect that it is Aqcuisition.Implicit. Well, Acquisition does not work in __getattr__. This seems trivially because the "self" is unwrapped in the case of __getattr__, while it's wrapped when called on a normal method. > > > The problem is, that __getattr__ does not have access to the acquisition > > chain. > > Well, it does, but it typically causes infinite recursion if you aren't Well, it would perhaps make sense for Acquisition to use the equivalent of getattr(self.aq_explicit,name) instead of getattr(aq_base(self),name) This way you have no infinite recursion, but still can acquire things explicitly with aq_acquire :) > careful. Something like this might work (this is untested code, adapted from > something that is a bit more complex that we are doing): > > def __getattr__(self, name, marker=None): > if not name.startswith('_') and not name.startswith('aq_'): > if not name in self._v_ignore_attrib: > subob = getattr(self,name,_marker) Well, where do you intenden your getattr to get the attribute from? > self._v_ignore_attrib=[] > # Return it in context of self, forgetting > # its location and acting as if it were located > # in self. > return aq_base(subob) > else: > self._v_ignore_attrib.append(name) > > raise AttributeError, name > > > > Basically I want "Transparent Folders" which get their "transparent > > values from the Acquisition path. > > Aha. Well, I wouldn't call it trivial, but it is definitely doable. Difficult. Because __getattr__ does not have access to the acquisition chain. (Just looking at Acquisition.c makes my head go all jelly ;) ) 1.) Change Acquisition to call getattr not on self but on an explicit wrapper of self. see above. Problem: Compability with Zope? Should probably work. But perhaps there are things that rely on self being the object and not an explicit Wrapper. Problem: The idea of patching Acquisition.c makes my head spin. Problem: Not possible to fix it up as an Product -> needs a patch to Zope. 2.) Fetch my a wrapped copy of self from the Python call stack. Problem: It's an example of code that would be labelled "Do not copy this style!" Problem: Can break at the most curious moments. 3.) Store the wrapped self in some attribute during traversal. Problem: This is plain wrong. It's not safe in a number of ways, ... (threads, multiple acquisition paths, etc.) I've implemented solution 2) because - it's packable as a product - I'm not sure a core change to Acquisition.c is something that has ANY chance of getting into Zope. - I'm not 100% sure that changing Acquisition.c will not break Zope in some subtle ways. - I'm already past the delivery deadline for my small application of this. Hacking the Python stack seems something that I can predict much better than any try to hack Acquisition.c :( Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] __getattr__ and Acquisition
Am Mon, 2002-09-23 um 00.18 schrieb Lennart Regebro: > From: "Andreas Kostyrka" <[EMAIL PROTECTED]> > > I've just discovered, that Acquisition does not work with __getattr__, > > right? > > That depends on what you mean with "does not work". :-) > > > (I assume that this is so because something like getattr(mybase,attr) is > > called during the acquisition process to prevent infinite recursion.) > > > > Anyway to get around that? (To basically get a wrapped self from > > somewhere?) > > That's what self usually is... :-) Nope it is not. In a normal method you can access something acquired like this: self.acquired_value. Even more, this works for __bobo_traverse__. It just works for the publishing not accessing my attributes later on during publication. The problem is, that __getattr__ does not have access to the acquisition chain. Now I storing the "acquisition chain" in the object is not a sound proposition, because it is not thread safe. Worse the object might be accessed in some way that makes the acquisition chain not be updated. > > I think you need to answer a couple of questions: > 1. What is it you want to do? > 2. How are you trying to do it? > 3. What is happening when you try to do it? It's actually trivial ;) I want to acquire some things in __getattr__. Basically I want to insert an additional access step like this: 1.) a.b.c.o -> o if o exists in c 2.) a.b.c.o -> Folder.o (where Folder is acquired from a.b.c) if it's exist. 3.) a.b.c.o -> tries to acquire o from a.b.c. Basically I want "Transparent Folders" which get their "transparent values from the Acquisition path. Well, I just had an idea for an implementation: Third idea: I return some callable object the was generated specifically for the access from the __getattr__. This is than executed with Acquisition enabled, so it can try to get the real one, Problem: What if the attribute does not exist? I do not thing that Zope reacts to well when instead of a AttributeError exception it gets some object that raises AttributeError when accessed, Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] __getattr__ and Acquisition
Hi! I've just discovered, that Acquisition does not work with __getattr__, right? (I assume that this is so because something like getattr(mybase,attr) is called during the acquisition process to prevent infinite recursion.) Anyway to get around that? (To basically get a wrapped self from somewhere?) I see two "solutions": -) I let some method (like pretraversal) acquire my object and store a reference in my object. This might work if the object is changed seldom and the method is called regularly enough, ... -) I walk the frame stack and extract the wrapped self from it. Not really nice, but then Zope does a number of black magic things :) Andreas ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Namespaces, ZPublisher, DocumentTemplate question
Hi! I've got a product that inherits from Folder, and creates some magic "content" by overriding __bobo_traverse__. Now I've got the problem that I cannot access the "magic" items from within a DocumentTemplate like in . The interesting thing is, that I've overloaded __getattr__ and __getitem__, and it seems both are never called. (Actual code snippets at the end) So I'm wondering how DocumentTemplates (and say Page Templates) access the items and properties? Andreas code snippet: def __getattr__(self,k,*args): r=Folder.Folder.__getattr__(self,k,*args) print "__getattr__(%r,%r)==%r" % (self,key,r) return r def has_key(self,key): r=Folder.Folder.has_key(self,key) print "%r.has_key(%r)==%r" % (self,key,r) return r def __getitem__(self,key): print "__getitem__(%r,%r)" % (self,key) try: return Folder.Folder.__getitem__(self,key) except KeyError: try: return self.__bobo_traverse__(self,None,key) except AttributeError: raise KeyError,key ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Minor "bug"
Hi! I've just noticed with 2.1.6, that after clicking "Minimize" or "Full Sweep" on /Control_Panel/Database/manage_cacheGC, the resulting page is missing most Tabs and one has to click "Contents" to get all tabs. Maybe this is intentional, but it seems like (very) minor bug to me. Andreas -- Andreas Kostyrka | [EMAIL PROTECTED] phone: +43/1/7070750 | phone: +43/676/4091256 MTG Handelsges.m.b.H.| fax: +43/1/7065299 Raiffeisenstr. 16/9 | 2320 Zwoelfaxing AUSTRIA http://www.euro.cauce.org/ | http://www.cauce.org/ ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )