[Zope-dev] Product version number redundancy with version.txt and setup.py
Hi, Am I right in thinking that there is a duplication of information in having an eggified product's version number stored in setup.py and version.txt? Both seem to be necessary - the first for use with pypi and the second so that Zope knows what version of a product it has. The former seems more like it should be the preferred single place for this information. Does anyone have any ideas about how we might update Zope to read version information from setup.py instead? The initializeProduct function at http://svn.zope.org/Zope/trunk/lib/python/App/Product.py?rev=73460view=auto seems to be the relevant place. However, I'm not sure if that code has access to the full eggy package at that stage. My guess is that the relevant object (productp?) might already have been adjusted for backward compatibility reasons at that stage. Any ideas? Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )
[Zope-dev] Resolution of issue #2333 before next maintenance release(s)?
Hi, Apparently a maintenance release for 2.10 is imminent. Would it be possible for someone to review the report for issue #2333 @: http://www.zope.org/Collectors/Zope/2333. The fix provided there comes with a test. If it's deemed suitable, could someone with commit privileges apply the patches before the release is cut? If not, could they tell me what I need to do to have it accepted? Thanks, Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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] Re: Resolution of issue #2333 before next maintenance release(s)?
Tres Seaver wrote: Tres Seaver wrote: Tim Hicks wrote: Hi, Apparently a maintenance release for 2.10 is imminent. Would it be possible for someone to review the report for issue #2333 @: http://www.zope.org/Collectors/Zope/2333. The fix provided there comes with a test. If it's deemed suitable, could someone with commit privileges apply the patches before the release is cut? If not, could they tell me what I need to do to have it accepted? I am in the process of landing the test and fix on the Five 1.3, 1.4, and 1.5 branches and the Five trunk. Question for Andreas / Stefan: would it be alright if I blow away the release tags for Five 1.3.9 / 1.5.4 pseudo-releases? No tarballs / release announcements were made, AFAIK, and the only clients are the svn:externals links in the Zope2 tree. OTherwise, I need to create new releases, and change the Zope2 links. For the record, I chose the second path after thinking it over a bit. Thanks for seeing to this! Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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] local namespace optimizations?
Florent Guillaume wrote: Is anyone opposed to me removing the stupid: _getattr = getattr _none = None marker = _marker local namespace optimizations that are found in unrestrictedTraverse? I find these things rather confusing when looking at zope core code, and always wondered why they were there. In what sense are they optimisations? Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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] Re: Wishlist Item
Tino Wildenhain wrote: Maybe its just me but I personally dont like direct filesystem access in the core - if someone wants it, (s)he can pick from the 3rd party products - maybe there can be a list of recommended (active maintained) products? Direct access products should also carry some easily understandable warnings. I can understand that point of view for products that allow writing to the filesystem, but, conceptually, what's the difference between read-only filesystem access and a standard filesystem product? None, I think, but then I may have misunderstood the purpose of FileSystemSite, and friends. Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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] Make objectValues return a generator?
Petri Savolainen wrote: Am I right in assuming that calls to objectValues etc. still return a real sequence of objects loaded in memory from ZODB? How about making object* calls return a generator instead? Has this been discussed somewhere already? I tried a bit of googling list-searching but could not find much anything on this. Funny you should ask, I played with something similar the other day. I wanted superValues-like functionality for CMF portal_types. Take a look at http://svn.plone.org/view/collective/PloneboardPluggableDiscussion/trunk/utils.py?rev=10024view=markup for some rather inelegant looking code the implements this as an iterator. It's a bit different from what you're after as the gain isn't in the contentValues call (which is the equivalent of your objectValues), but rather in the fact that only the smallest number of those calls that are needed is made. Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )
[Zope] blacklisting referers and/or specific hosts
Hi, I have a zope site up and running which has recently had a *lots* of hits from a client (or clients) that show referers pointing at various gambling, meds, and loan sites. Requests only come in for the main page, not for the associated images, css, etc that should go with it. The consequence is that my server is working harder to service a client that isn't interested in what it has to say, and my Z2.log is now far less useful to me as all these bogus requests drown out most of the useful information. So, I'm wondering if there's a way to blacklist those clients that I don't like based on host/ip and/or on referer. If I hook into the traversal process in the same way as the virtual host monster objects do, could I check the request against my blacklist and then do a REQUEST.close()? Would that still appear in my logs? Does that even make sense? Is there a HTTP response code that I could return to these clients that would stop them being interested in my server? Any ideas much appreciated. Tim ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope-dev] 2.8.0b1 issues with plone 2.0.5
Apologies if this is already known about... I just installed 2.8.0b1 (using python 2.3.5), fired it up, then tried to add a 'plone site' (2.0.5). The plone site actually did get added, but here's what I got as well: 2005-04-24 12:57:32 ERROR Zope.ZCatalog Recataloging object at /test/test/index_html failed Traceback (most recent call last): File /home/tim/zope/2.8.0b1/lib/python/Products/ZCatalog/ZCatalog.py, line 298, in refreshCatalog self.catalog_object(obj, p, pghandler=pghandler) TypeError: catalog_object() got an unexpected keyword argument 'pghandler' 2005-04-24 12:57:34 ERROR Zope.SiteErrorLog http://glenmore.dyndns.org:7080/test/test/index_html Traceback (most recent call last): File /home/tim/zope/2.8.0b1/lib/python/ZPublisher/Publish.py, line 113, in publish request, bind=1) File /home/tim/zope/2.8.0b1/lib/python/ZPublisher/mapply.py, line 88, in mapply if debug is not None: return debug(object,args,context) File /home/tim/zope/2.8.0b1/lib/python/ZPublisher/Publish.py, line 40, in call_object result=apply(object,args) # Type scr to step into published object. File /home/tim/zope/2.7.4b2/Products/CMFCore/PortalContent.py, line 116, in __call__ return view() File /home/tim/zope/2.8.0b1/lib/python/Shared/DC/Scripts/Bindings.py, line 311, in __call__ return self._bindAndExec(args, kw, None) File /home/tim/zope/2.8.0b1/lib/python/Shared/DC/Scripts/Bindings.py, line 348, in _bindAndExec return self._exec(bound_data, args, kw) File /home/tim/zope/2.7.4b2/Products/CMFCore/FSPageTemplate.py, line 191, in _exec result = self.pt_render(extra_context=bound_names) File /home/tim/zope/2.7.4b2/Products/CMFCore/FSPageTemplate.py, line 124, in pt_render result = FSPageTemplate.inheritedAttribute('pt_render')( File /home/tim/zope/2.8.0b1/lib/python/Products/PageTemplates/PageTemplate.py, line 96, in pt_render c = self.pt_getContext() TypeError: unbound method pt_getContext() must be called with ZopePageTemplate instance as first argument (got nothing instead) ___ Zope-Dev maillist - Zope-Dev@zope.org 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] 2.8.0b1 issues with plone 2.0.5
Tim Hicks said: File /home/tim/zope/2.8.0b1/lib/python/ZPublisher/Publish.py, line 40, in call_object result=apply(object,args) # Type scr to step into published object. File /home/tim/zope/2.7.4b2/Products/CMFCore/PortalContent.py, line 116, in __call__ return view() Eek, just noticed that for some reason I seem to have some 2.7.4b2 mixed up in here. Not sure how/why that would happen. I have one copy of all my products and then symlink to them for each of my zope instances. Could it be the cause of my problem? tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )
[Zope] Security on email.Message.Message
Hi, I'm trying to import and use the email.Message.Message class in a zope 'Script (Python)'. I have the following security assertions in my product code:: from AccessControl import allow_module, allow_class from AccessControl import ModuleSecurityInfo ModuleSecurityInfo('email.Message').declarePublic('Message') from email.Message import Message allow_class(Message) As a result, I can successfully import like:: from email.Message import Message I can even create an instance and call most methods on it:: m = Message() m.set_payload('read that') However, when I try to use the mapping interface, I get an error. For example, the following:: m['from'] = '[EMAIL PROTECTED]' produces a traceback like:: Traceback (innermost last): Module ZPublisher.Publish, line 101, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 39, in call_object Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec Module Products.PythonScripts.PythonScript, line 323, in _exec Module None, line 6, in AAA - PythonScript at /test/AAA - Line 6 Module RestrictedPython.Guards, line 96, in handler TypeError: object does not support item or slice assignment Does anyone have any idea what the problem is? Tim ps Not subscribed here, so please do cc me with replies. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Security on email.Message.Message
Andreas Jung said: Module RestrictedPython.Guards, line 96, in handler TypeError: object does not support item or slice assignment Does anyone have any idea what the problem is? Move your code into an external method which is less painful than dealing with module security issues. As an alternative: look at TrustedExecutables. Thanks Andreas. I suppose I could move the code to a product (which I would prefer over an external method), but it seems a little heavy-weight for my requirements. In fact, generally, I think I would like to be able to use email.Message.Message instances in TTW code, so if anyone does know what's going wrong here, I'd be most pleased to hear. Tim ps Is it me or is the traceback I'm seeing not particularly helpful? I mean, I know that these objects *do* support the dictionary interface! ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Security on email.Message.Message
Andreas Jung said: Module RestrictedPython.Guards, line 96, in handler TypeError: object does not support item or slice assignment Does anyone have any idea what the problem is? Digging further... I made the TypeError a little more revealing on line 96 of RestrictedPython/Guards.py so it now shows the 'secattr' (method) being accessed, and its args:: def handler(self, *args): try: f = getattr(self.ob, secattr) except AttributeError: raise TypeError, '%s | %s | %s' % (error_msg, secattr, str(args)) The value of 'secattr' is apparently '__guarded_setitem__' in my case. So, it seems that the email.Message.Message class does not have a __guarded_setitem__ on it. This is unsurprising. I assume that it is supposed to get added during zope initialisation somewhere, right? Can anybody point out where? Tim ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Security on email.Message.Message
Tim Hicks said: Andreas Jung said: Module RestrictedPython.Guards, line 96, in handler TypeError: object does not support item or slice assignment Does anyone have any idea what the problem is? Digging further... I made the TypeError a little more revealing on line 96 of RestrictedPython/Guards.py so it now shows the 'secattr' (method) being accessed, and its args:: def handler(self, *args): try: f = getattr(self.ob, secattr) except AttributeError: raise TypeError, '%s | %s | %s' % (error_msg, secattr, str(args)) The value of 'secattr' is apparently '__guarded_setitem__' in my case. So, it seems that the email.Message.Message class does not have a __guarded_setitem__ on it. This is unsurprising. I assume that it is supposed to get added during zope initialisation somewhere, right? Can anybody point out where? Well, I've fixed this with an awful hack. My security assertions now look like:: from AccessControl import allow_module, allow_class from AccessControl import ModuleSecurityInfo def _secure_mapping(klass): XXX Awful hack!! klass.__guarded_getitem__ = klass.__getitem__ klass.__guarded_setitem__ = klass.__setitem__ klass.__guarded_delitem__ = klass.__delitem__ ModuleSecurityInfo('email.Message').declarePublic('Message') from email.Message import Message _secure_mapping(Message) allow_class(Message) That gets me to where I want (for now). I'd still love the 'correct' answer though. Tim ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope-dev] Re: CookieCrumbler and User-Logging
Tres Seaver said: I am attaching the patch which Casey Duncan worked up to log the cookie-based user somewhat more cleanly. Hi Tres, I'm just wondering what the status of this patch is. I mean, is it now part of any (forthcoming) release of cookiecrumbler or CMF? Does it have any downsides? Would you install it on a production server? Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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] Re: CookieCrumbler and User-Logging
Tres Seaver said: | Does it have any downsides? I can't recall whether the patch includes a knob to turn off the logging behavior. If not, I would want to add one before checking it in. It does have that knob. | Would you install it on a production server? We have done so for some hosted customers who wanted the capability to track their users. Well, on the strength of that, I've installed it too, and it seems to work nicely. Thanks. Tim ___ Zope-Dev maillist - Zope-Dev@zope.org 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 )
[Zope-dev] 2.7 and 2.8 roadmap
Hi, just wondering what the plans are for zope 2.7 and 2.8. Specifically: 1) When is the recent release of 2.7.4b2 expected to be followed up with a 'final' (or indeed another beta) release? 2) I have seen mutterings about a 2.7.5 release, but I'm not sure why this should be necessary as I thought all 'dot releases' were only supposed to provide bug-fixes. Seeing as we're still on beta for 2.7.4, shouldn't any outstanding fixes go into that? 3) Are there plans for another 2.8 (alpha or beta) release in the near future? Is there a timeline for this? Are ZC or anyone else hanging out for this? Personally, I'm pretty keen to be able to persist new style classes (for use with the email.Message.Message class). The wiki at http://dev.zope.org/Wikis/DevSite/Projects/Zope2.8/FrontPage seems a little out of date. Just interested. cheers, tim ___ 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] 2.7 and 2.8 roadmap
Andreas Jung said: 1) When is the recent release of 2.7.4b2 expected to be followed up with a 'final' (or indeed another beta) release? 2.7.4 final is scheduled for early January. Ok, thanks. 2) I have seen mutterings about a 2.7.5 release, but I'm not sure why this should be necessary as I thought all 'dot releases' were only supposed to provide bug-fixes. Seeing as we're still on beta for 2.7.4, shouldn't any outstanding fixes go into that? Have you seen anything other than bugfixes in dot releases? Except some minor improvements all releases were bugfix releases only. No major new features were introduced. And new 2.7.X release will be made as long as outstanding bugs are fixed but not *every* outstanding will be fixed. That's fair enough. Thanks for the clarification. 3) Are there plans for another 2.8 (alpha or beta) release in the near future? Is there a timeline for this? Are ZC or anyone else hanging out for this? Personally, I'm pretty keen to be able to persist new style classes (for use with the email.Message.Message class). The wiki at http://dev.zope.org/Wikis/DevSite/Projects/Zope2.8/FrontPage seems a little out of date. There are some outstanding issues that must be fixed before the next alpha 2 (ZClasses, garbage collection). I don't know when Jim can work on this issue (there are only some people with the detail knowledge to fix these issues). Since I can not enforce people to work on particular issues, a2 will released when the outstanding issues are solved. I understand. FWIW, the two things I'd like are a stable 2.7 release in the short term to setup a new site on, and a stable 2.8 release to develop a new product on. Sounds like Santa (aka Andreas) will be bringing the former ;-). I think in the back of my mind, I was hoping that more people waiting on 2.8 to get their features into zope might speed things up on the latter - hence my wondering about the motivations for a 2.7.5 (which you have now cleared up). That said, I'm in no position to do anything other than inquire (in a most friendly and appreciative manner) about 2.8 as I'm certainly not on of the people with the 'detailed knowledge' to fix zclasses and garbage collection. cheers, tim ___ 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] connecting server code to the ZODB
Replying to myself in case anyone is interested in the answer to my problems... Tim Hicks said: Nope, I don't have a reference to a persistent object. I'm looking at the code in smtpserver.SMTPServer and trying to figure out what I need to adjust. As far as I can tell, the only point in that code at which a 'link' to zope/zodb objects is made is in the following call in SMTPChannel.process_message: handle(self.server.module, request, response) My immediate problem is that I don't understand how the result of this call gets dealt with. It just seems to get discarded in the smtpserver code. If this is the way to interact with the publisher, how do I get hold of the return value? I'm assuming that by adjusting the REQUEST['PATH_INFO'] value before calling handle(), I can affect which ZODB object/method gets called, but I want to know the result of this call. The REQUEST['PATH_INFO'] part is correct: that is how you determine which method gets traversed to and called. I discovered that you get hold of the return value from this method by passing a callback method into the response constructor. This gives you access to whatever arguments you arrange to have the callback called with *plus* the response object, which you can use to have a look at status codes etc. cheers, tim ___ 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] connecting server code to the ZODB
Paul Winkler said: Ok, so I could simply drop the Zope.startup() line and things would be fine (and quick), right? I haven't tried it, but I think doing Zope.app() will try to acquire a lock on the database and it is already locked by the running Zope (or ZEO). So I don't think you can do that. Ok, I think I follow that. I think you should use the existing publisher machinery. Given an SMTPRequest instance foo, you should be able to do foo.traverse(path, response) and get back an object. This monster method is defined in ZPublisher/BaseRequest.py What does using foo.traverse() buy me over simply accessing the ZODB objects 'by hand', as in root = Zope.app()? Well, for one thing it might actually work ;-) Good point :-). The only thing is that I'm not sure that I actually am able to call foo.traverse() before it gets passed into handle() (see below) because I don't think that it will be populated with 'PARENTS' before it's been 'sent to zope'. Note, I'm not sure what your code looks like - if you already have a reference to any persistent object (as long as it's Traversable which basically anything of interest to you would be), you can get the root by doing root = someObject.getPhysicalRoot(). Nope, I don't have a reference to a persistent object. I'm looking at the code in smtpserver.SMTPServer and trying to figure out what I need to adjust. As far as I can tell, the only point in that code at which a 'link' to zope/zodb objects is made is in the following call in SMTPChannel.process_message: handle(self.server.module, request, response) My immediate problem is that I don't understand how the result of this call gets dealt with. It just seems to get discarded in the smtpserver code. If this is the way to interact with the publisher, how do I get hold of the return value? I'm assuming that by adjusting the REQUEST['PATH_INFO'] value before calling handle(), I can affect which ZODB object/method gets called, but I want to know the result of this call. Any ideas? tim ___ 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] connecting server code to the ZODB
Paul Winkler said: What I really want to be able to do from the server code is something like:: root = magic_that_gets_me_zodb_root() That magic is basically (from memory): import Zope Zope.startup() root = Zope.app() But note that starting up a zope is slow, so you don't want to do that very often. Well, in this case zope is already running. Ok, so I could simply drop the Zope.startup() line and things would be fine (and quick), right? I think you should use the existing publisher machinery. Given an SMTPRequest instance foo, you should be able to do foo.traverse(path, response) and get back an object. This monster method is defined in ZPublisher/BaseRequest.py What does using foo.traverse() buy me over simply accessing the ZODB objects 'by hand', as in root = Zope.app()? It seems I get security by using foo.traverse() - although I'm not sure whether that is really necessary for my purposes. Would it also deal with any ZODB transaction stuff for me that I would otherwise have to sort out - get_transaction().commit(). If I'm just reading ZODB objects (not writing), does the transaction stuff even matter? thanks, tim ___ 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 )
[Zope-dev] connecting server code to the ZODB
Hi, I'm trying to figure out how to adjust Nikolay Kim's smtpserver code http://cvs.sourceforge.net/viewcvs.py/collective/smtpserver/ so that objects within the ZODB can affect the way that messages are received (i.e. veto messages based on certain criteria in the first instance). My problem is that I don't quite know how to get hold of the ZODB objects. As far as I can tell, Nikolay's smtpserver.SMTPServer.SMTPChannel.process_message method uses ZServer.PubCore.handle to make the connection, but I don't really understand how this all works. What I really want to be able to do from the server code is something like:: root = magic_that_gets_me_zodb_root() account_manager = root['Control_Panel']['AccountManager'] account_manager.checkAccepts(msg) I want calls like that to checkAccepts(msg) to be made a several points in the SMTP session - say after each of the SMTP commands RCPT, MAIL, DATA, etc. I only mention that in case there are implications for some transaction jiggery-pokery (although I don't expect any of the checkAccepts() type calls to need to write to the ZODB). Any pointers much appreciated. tim ___ 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 )
[Zope-dev] Bug in ExternalMethods?
I think I've found a bug in ExternalMethod, but I don't know if it's already been fixed or not. Basically, the call signature of ExternalMethods seems to get mixed up sometimes. I'm running Zope 2.5.1 on Linux. Here's a small demonstration of the bug: --test.py-- def test(self, a_string, an_int, a_named_arg=1): bug provoking? template = a_string = %s; type(a_string) - %s\n an_int = %s; type(an_int) - %s\n a_named_arg = %s; type(a_named_arg) - %s return template % (a_string, type(a_string), an_int, type(an_int), a_named_arg, type(a_named_arg)) --Script (Python)-- return container.test('tim', 10, a_named_arg=(1,1)) return container.test('tim', 10, (1,1)) You can see the dodgy behaviour by switching between the two test() calls in the Script (Python). tim ___ 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] bug in mapply.py?
Thanks for the reply Steve, Steve Alexander said: I must admit to not understanding why this should only break over xmlrpc and not directly from Zope. The problem appears to be that my method is defined something like: def method(self, *args, **kw) mapply doesn't put things into **kw arguments of methods. Yeah, that's what I understood to be the case. However, coming in over xmlrpc, I don't have any keyword arguments - I say that because that's explicitly what I'm doing, but I'm not sure xmlrpc handles keyword args anyway. The **kw is just there for easier use when the method is called directly from zope. I wanted this once for a product in Zope 3, looked deeply into mapply, and talked to Jim Fulton about it. IIRC, Jim said that mapply shouldn't put things into **kw arguments because it isn't at all explicit, and would end up implicitly putting in a whole bunch of things that you generally wouldn't want in a lot of cases. Can you make up a simple python module to demonstrate your case, just using a method, and mapply? I guess I could try, but I'm not convinced this is my problem at the moment. It may be that there's a way to achieve what you want, while still keeping things reasonably explicit. From what I can tell, the problem seems to be at line 58 (mapply.py): names=c.co_varnames[1:c.co_argcount] Given a call signature like: def method(self, *args, **kw) c.co_argcount == 1 c.co_varnames == ('self', 'args', 'kw') Now, 'names' (the variable) becomes only 'self' (the string) on line 58. In this way, mapply.py seems to ignore the fact that I want my method to accept an arbitrary number of arguments (line 69). I don't know if there's a good reason for this, or whether I'm doing things wrong. I also don't know why this only crops up over xmlrpc, as I presume mapply.py is used (in some way) from within zope as well. Any ideas? tim ___ 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 planning - call for contributors!
See below This isn't exciting by any means unless you're one of the people who package Zope up for distribution, or maybe you're one of the people who manage lots of little Zopes on one system; but I'd like to revive the grand unified Zope installation and control proposal that has been floated by many people (including me) in one form or another for some time. Wikiwise, this would wrap up http://dev.zope.org/Wikis/DevSite/Proposals/ZopeStartupProvisions and http://dev.zope.org/Wikis/DevSite/Proposals/InstallationAndConfiguration, at least. To summarize, this would involve - an expanded build program with an installation scheme that would allow multiple versions of Zope to be present on the same system - making that installation 'secure by default' - a registry of Zope installations and one of instances and their configuration settings - a 'zopectl' program or similar that would be able to start and stop instances - a 'zopeinstance' program or similar that would become the _recommended_ way of setting up Zope, by creating an INSTANCE_HOME It would be nice if - the same framework could apply to Zope 3, maybe taking care of that piece ahead of time I'm more than willing to head this up, though I question how long we have before 2.6 to do so. Matt, I read 'InstallationAndConfiguration' page, and it made me wonder exactly how that aspect would work. Assuming some sort of distutils based setup [1], would something like the following be the desired approach? [2] #Installs zope in it's current simplest configuration. Equivalent of python wo_pcgi.py $ python setup.py #Equivalent of w_pcgi.py $ python setup.py pcgi #Creates SOFTWARE_HOME or ZOPE_HOME (I'm not sure if there's a difference, or which one I would mean) #I guess it would just do this in the current directory $ python setup.py zope_home #Creates an INSTANCE_HOME by prompting the user for a path (if not already given) to install to #Add's instance to some sort of registry [3] $ python setup.py instance [/path/to/instance] I don't really know what else to think about. I haven't ever used ZEO, so I don't have the first clue about that side of things. So, as you may be able to tell, I'm a little hazy on many (most?) aspects of this install/configure idea, but I'm quite keen on it. I've tried to post something that is at least mildly useful more in the hope that it may keep the proposal rolling rather than as a 'me too' or '+1' (as Paul E already told us off for ;-) ). I guess, at the end of the day, I can't really get around the fact it's a 'me too' without any coding commitment [4]. Do you have any concrete ideas for this? cheers tim [1] I've never used distutils before [2] Feel more than free to knock down and tear up anything I've said here :-) [3] Would this 'registry' be some sort of flat text file, or perhaps a zodb store, or...? [4] Apart from the fact that I've never written anything other than web-code (so my python probably isn't up to it), I can't commit time at the moment due to my degree having to take priority :-(. If there were any simply odd-jobs, testing, something I couldn't ballsup, I'd like to help if I can. ___ 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] Script to do various 'manage_' operations
I have been trying to get hold of a script that can automatically convert various dtml methods to custom zclass instances. I found a script on the zope mailing list (see bottom) I put my file (see below) in the Extensions directory and added an external method from within zope. This all appeared to go fine. To execute the script, I made a method that simply had dtml-call conscript() and then standard_h_h etc. The problem is, nothing seems to happen. I can view the method that was supposed to run the script, but the call doesn't seem to work. Within the filesystem, there is no file called tempo (as a kind of log of what's been done), and the methods with extension .shtml certainly do not get changed to dtml documents. Has anyone done this before? Can you shed any light on what I'm doing wrong? Much obliged. tim Script from [EMAIL PROTECTED] --- import re def convert_dtml(self): """Convert DTML Methods and DTML Documents from old syntax to new syntax. Warning: recursive! This assumes that DTML Method and DTML Document haven't been subclassed. """ print 'convert_dtml: id=%s' % self.title_and_id() if hasattr(self, 'meta_type') and \ (self.meta_type == 'DTML Method' or \ self.meta_type == 'DTML Document'): convert(self) # should this be "isPrincipiaFolderish"? if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager: for v in self.objectValues(): v.convert_dtml() _convert_regex = re.compile('''!--#(/?)(([^"-]+?|"[^"]*?"|'[^']*?'|-[^-])+?)--''') def convert(dtml_item): print 'converting...' title = dtml_item.title # like document_src, but doesn't require RESPONSE data = dtml_item.PrincipiaSearchSource() print 'data' print data newdata = _convert_regex.sub('\g1dtml-\g2', data) print 'newdata' print newdata print 'end' dtml_item.manage_edit(newdata, title) -- And here is how I adjusted it for my purposes: -- import re get_shtml = re.compile('\w+\.shtml') f = open("tempo", "w+") def convert_dtml(self): """Convert DTML Methods and DTML Documents from old syntax to new syntax. Warning: recursive! This assumes that DTML Method and DTML Document haven't been subclassed. """ if hasattr(self, 'meta_type') and \ get_shtml.match(self.id): convert(self) # should this be "isPrincipiaFolderish"? if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager: for v in self.objectValues(): v.convert_dtml() def convert(dtml_item): id = dtml_item.id+'2' title = dtml_item.title # like document_src, but doesn't require RESPONSE f.write(id /n) data = dtml_item.PrincipiaSearchSource() PARENTS[0].manage_addDTMLDocument(id, title) id.manage_edit(data, title) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] document_src not doing what I thought it did
- Original Message - From: Dieter Maurer [EMAIL PROTECTED] To: Tim Hicks [EMAIL PROTECTED] Sent: Friday, January 12, 2001 10:28 PM Subject: Re: [Zope] document_src not doing what I thought it did Tim Hicks writes: I have a dtml-documentish zclass and have created a custom edit method for it so that I can do an automatic reindex when each instance is edited. I created this custom form by simply copying the source html that is generated for the standard edit form, and then replacing the static parts of what I copied with various dtml-var inserts (see below). This seemed to go according to plan until I realised that something strange is happening when I try to view this edit form for an instance of the zclass. In most cases, everything seems normal, but when I try to edit an instance that has a property set to 'private', my 'privacy' method kicks in and redirects me away from the edit form to my standard 'Restricted Page'. The redirection is written into the text of the instance I am trying to edit, so I expected that by using dtml-var document_src, the actual source would get placed in the text area without being processed. This is what appears to happen when the instance does not have the 'private' property. I guess therefore, my question is, am I using document_src correctly? Is is possible that your edit form is called in the context of you ZInstance? I'm not sure I completely understand the terminology you use, but I guess it sounds right that the edit form method is called 'on' (in my terminology ;-) ) the Zclass instance. It is in that way that the dtml-var id/title/get_size/etc retrieve the attributes of the instance and not the method itself... is that correct? Is that what you mean? Then, it might be able that *it* interpretes the "private" and redirects before "document_src" is executed at all. Each Zclass instance has dtml-call privacydtml-if "available* == 1"dtml-call RESPONSE.redirect(restricted)dtml-elseblah/dtml-if . (* set by the privacy method). Thanks for your help with that btw :-). However, the edit form method does not have this code in it. As far as I can gather, the only time the method gets to 'see' the code shown above is when it inserts dtml-var document_src. What am I missing? tim Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] reindex when a zclass is edited
- Original Message - From: Aleksander Salwa [EMAIL PROTECTED] To: Tim Hicks [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 12, 2001 8:34 AM Subject: Re: [Zope] reindex when a zclass is edited On Thu, 11 Jan 2001, Tim Hicks wrote: from a builtin edit form as my template. One thing doesn't work now though, and that's making the textarea wider/narrow/etc. Obviously, this is because I have static values put in for the dimensions of the text area, but I'm not sure how to alter this to make it work... any pointers? I use this code for that purpose: dtml-if "REQUEST.has_key('dtpref_cols')" dtml-if "REQUEST.has_key('dtpref_rows')" dtml-var "manage_edit(data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST)" dtml-else dtml-var "manage_edit(data,title,SUBMIT,dtpref_cols,REQUEST=REQUEST)" /dtml-if dtml-else dtml-if "REQUEST.has_key('dtpref_rows')" dtml-var "manage_edit(data,title,SUBMIT,dtpref_rows=dtpref_rows,REQUEST=REQUEST)" dtml-else dtml-var "manage_edit(data,title,SUBMIT,REQUEST=REQUEST)" /dtml-if /dtml-if dtml-call "reindex_object()" dtml-call "RESPONSE.redirect(manage_edycjaTresciForm.absolute_url())" Thanks very much for the help Aleksander, but when I drop your code into my method, it doesn't work (it doesn't break either). I simply copied and pasted your code, then edited the final redirect at the bottom. Here is the submission part of my edit form (if it makes any difference). TD align=left INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change" /TD TD align=left INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Narrower" /TD I had a look on the ZQR, and found the section on manage_edit, but I still don't really understand how the dtpref_cols/rows works. Any insight? Cheers tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] reindex when a zclass is edited
- Original Message - From: Ivan Cornell [EMAIL PROTECTED] To: Tim Hicks [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, January 10, 2001 7:53 PM Subject: Re: [Zope] reindex when a zclass is edited Tim Hicks wrote: I can't for the life of me figure out or find anywhere that can tell me how to make the instance get reindexed when it is edited. I'm assuming that it is similar to the process for reindexing when the properties are changed, but I'm just not sure of the details. If it's not too much trouble, could someone give me detailed instructions (or a link) on how to do this. I'd really appreciate it. In your method which is called by your edit form, insert a dtml-call "this().reindex_object()" after updating the properties. Eg, in my manage_edit method I have dtml-call "propertysheets.Base.manage_editProperties(REQUEST)" dtml-call "propertysheets.Facility.manage_editProperties(REQUEST)" dtml-call "this().reindex_object()" Regards, Ivan Much obliged Ivan, I have managed to do it now. I ended up creating my_editForm and my_edit methods within the zclass and then using the source from a builtin edit form as my template. One thing doesn't work now though, and that's making the textarea wider/narrow/etc. Obviously, this is because I have static values put in for the dimensions of the text area, but I'm not sure how to alter this to make it work... any pointers? my_edit looks like this btw, htmlbody dtml-call "manage_edit(data, REQUEST.title)" dtml-call reindex_object dtml-call "RESPONSE.redirect(absolute_url()+'/my_editForm')" /body/html Does this seem appropriate? cheers tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] document_src not doing what I thought it did
I have a dtml-documentish zclass and have created a custom edit method for it so that I can do an automatic reindex when each instance is edited. I created this custom form by simply copying the source html that is generated for the standard edit form, and then replacing the static parts of what I copied with various dtml-var inserts (see below). This seemed to go according to plan until I realised that something strange is happening when I try to view this edit form for an instance of the zclass. In most cases, everything seems normal, but when I try to edit an instance that has a property set to 'private', my 'privacy' method kicks in and redirects me away from the edit form to my standard 'Restricted Page'. The redirection is written into the text of the instance I am trying to edit, so I expected that by using dtml-var document_src, the actual source would get placed in the text area without being processed. This is what appears to happen when the instance does not have the 'private' property. I guess therefore, my question is, am I using document_src correctly? thanks very much tim ps Sorry to be such a regular poster of problems FORM ACTION="my_edit" METHOD="POST" TABLE CELLSPACING="2" TR TH ALIGN="LEFT" VALIGN="TOP"Id/TH TD ALIGN="LEFT" VALIGN="TOP"dtml-var id/TD /TR TR TH ALIGN="LEFT" VALIGN="TOP"EMTitle/EM/TH TD ALIGN="LEFT" VALIGN="TOP" INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="dtml-var title" /TD /TR tr th align="left" valign="top" emSize/em /th td align="left" valign="top" dtml-var get_size bytes /td /tr tr th align="left" valign="top" emLast modified/em /th td align="left" valign="top" dtml-var bobobase_modification_time /td /tr TR TD COLSPAN="2" ALIGN="CENTER" TEXTAREA NAME="data:text" WRAP="Off" COLS="115" ROWS="25"dtml-var document_src/TEXTAREA /TD /TR TR TD align=left INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change" /TD TD align=left INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider" INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Narrower" /TD /TR /TABLE /FORM ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] inserting half a dtml tag into a zclass
- Original Message - From: Dieter Maurer [EMAIL PROTECTED] To: Tim Hicks [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, December 29, 2000 9:38 AM Subject: Re: [Zope] inserting half a dtml tag into a zclass Tim Hicks writes: This is a multi-part message in MIME format. --=_NextPart_000_0009_01C07071.533E96C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable You are here long enough: you should know, we do not like MIME messages. My apologies. You're right, I do know better... my mistake. Also, apologies for the delayed reply, I've been away. ... isolating privacy checks ... dtml-var privacy dtml-var standard_html_header dtml-var standard_html_footer /dtml-if I know about 2 possible approaches: I. let your "privacy" method return a value (using "dtml-return") and check it above: dtml-if privacy ...header... ... ...footer... /dtml-if I've gone for a 'method' based on this first idea of yours. Here is what appears in each zclass instance. dtml-call privacy dtml-if "available == 1" dtml-call "RESPONSE.redirect(restricted+'/restricted.html')" dtml-else dtml-var standard_html_header dtml-var standard_html_footer /dtml-if And here is the privacy method. dtml-call "REQUEST.set('available', 0)" dtml-if "propertyLabel(availability) == 'private'" dtml-call "REQUEST.set('available', 1)" /dtml-if dtml-call "REQUEST.set('dom', _.string.split(REQUEST.REMOTE_ADDR, '.'))" dtml-if "dom[0] == '192'" dtml-if "dom[1] == '168'" dtml-call "REQUEST.set('available', 0)" /dtml-if /dtml-if dtml-in PARENTS dtml-let PARENT="_.getitem('sequence-item')" dtml-if "PARENT.hasProperty('dehs_site_root_folder')"dtml-call "REQUEST.set('restricted', PARENT.absolute_url())"/dtml-if /dtml-let /dtml-in It's not perfect (that would be when there is nothing for the user to break in each instance), but it's better than it was and also allows me to edit only one privacy method to change the access rights. II. I think (this implies, I am not sure), that ZPublisher translates exceptions into HTTP response codes. This would mean, you could try: In your "privacy" method: dtml-call "RESPONSE.redirect(...)" dtml-raise type="Redirect"/dtml-raise in your other objects: dtml-call privacy ...header... ...footer... You've lost me a bit there. Where am I actually checking to see if the user has access rights? Cheers tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] reindex when a zclass is edited
I know this has been asked numerous times before (once by me!), and I'm sorry to cover the same ground again, but I've spent all afternoon searching through the list archives to no avail. I have a zclass that is catalogaware (selected first and all that). When I add an instance, it gets cataloged and all is fine. I followed the how to (http://www.zope.org/Members/AlexR/CatalogAware) and successfully made my instance get reindexed when the properties are changed, but I can't for the life of me figure out or find anywhere that can tell me how to make the instance get reindexed when it is edited. I'm assuming that it is similar to the process for reindexing when the properties are changed, but I'm just not sure of the details. If it's not too much trouble, could someone give me detailed instructions (or a link) on how to do this. I'd really appreciate it. cheers tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] inserting half a dtml tag into a zclass
OK, I'm sorry for the wierd title, but I can't really describe what I want to say very easily in one line. Basically, my problem is this; - I have a zclass called DEHS with catalog_aware and dtml_document as base classes. - DEHS instances have a selectable property of public/private. - I want to be able to make it so that if the property is set to 'private', then only people on a particular network may access it. So, here is what I have done (and it works), dtml-call "REQUEST.set('available', 0)"dtml-if "propertyLabel(availability) == 'private'"dtml-call "REQUEST.set('available', 1)"/dtml-if dtml-call "REQUEST.set('dom', _.string.split(REQUEST.REMOTE_ADDR, '.'))"dtml-if "dom[0] == '192'"dtml-if "dom[1] == '168'"dtml-call "REQUEST.set('available', 0)"/dtml-if/dtml-if dtml-if "available == 1"dtml-in PARENTSdtml-let PARENT="_.getitem('sequence-item')"dtml-if "PARENT.hasProperty('dehs_site_root_folder')"dtml-call "REQUEST.set('restricted', PARENT.absolute_url())"/dtml-if/dtml-let/dtml-indtml-call "RESPONSE.redirect(restricted+'/restricted.html')"dtml-else dtml-var standard_html_header dtml-var standard_html_footer/dtml-if So, what's the problem I hear you ask. Well, I don't really want all this code to be visible (or breakable) in every DEHS instance. What I would really like to do is have this, dtml-var privacy dtml-var standard_html_header dtml-var standard_html_footer /dtml-if where, dtml-var privacy is just all of the code that I have above s_h_h.However, zope will not let me do this because I end up with a dtml-if thatis missingits closing tag, and one that does not have an opening tag. I realise that I there are products already designed with the sort of functionality I am after built in, but I will not have much influence on the products that will be available on the server that this site will end up on... which is why I'm doing it in this way. Any input is much appreciated. cheers tim
[Zope] dtml-in over the output from my method
I am trying to create a zope product in python but have got stuck with using the dtml-in tag to iterate over a method (or is it a function? I get a little mixed up) of my class. Here is the method, def list_messages(self): lr = open(self.user_dir+'/msg_list', 'r') spl = re.compile('\s\|\s') for msg_line in lr.readline(): num_from_sub = [] num_from_sub = spl.split(msg_line, 2) print num_from_sub self.msgnum = num_from_sub[0] self.msgfrom = 'This is from UNKNOWN' self.msgsub = 'My special subject' return self.msgnum, self.msgfrom, self.msgsub And here isan extract from the dtml file that is supposed to display the output, dtml-in list_messages tr tda href="/spool/dtml-user;/get_message?dtml-msgnum;"dtml-msgfrom;/a/td tda href="/spool/dtml-user;/get_message?dtml-msgnum;"dtml-msgsub;/a/td /tr/dtml-in However, this does not produce the desired effect. I don't know if it is obvious from what I've written, but basically, the three variables (self.msgnum, self.msgfrom and self.msgsub) are supposed to be inserted into the appropriate place in the table, and then the 'for' statement re-executed (producing different values for the variables) with the subsequent values being inserted into the next line of the table etc... until there are no more lines to be read from lr. I'm not sure if that is clear or not, sorry. Obviously, this does not work as the dtml-in simply iterates over each of the returned variables (instead of over the for statement). I can't seem to make it do what I want. Does anyone have any ideas? Much obliged if you do. Cheers tim
[Zope] testing a product, then it disappears after restart
I am trying to create a zope product and it basically works in python, so I thought I would start trying to 'zopify' it. I created a directory in the zope Products directory called zIMAP and placed my code in there, along with a __init__.py file to initialise the product. Here is what it looks like, import zIMAP def initialize(context): """Initialize the zIMAP product.""" context.registerClass( zMAP.zimap,constructors = (zIMAP.manage_addzIMAPForm,zIMAP.manage_addzIMAP),icon = '') The main bit of my product code is in a file called zIMAP.py. When I restarted zope, my zIMAP product appeared in the product management list (broken, as I'd expected). I looked at the debug info that zope provides for broken products and made some changes to the code... followed by restarting zope. I then got a different error from the broken product info screen. However, when I made changes to the code and restarted zope this time, it was as ifI had done nothing. The same error was there (despite that particular line of code being different, and in fact at a different line). I could not make zope recognise my changes no matter how many times I restarted zope. So I tried deleting the product from the product management screen. It did indeed go away, but now it won't come back! When I delete any other working product, it simply reappears next time I restart zope. What has gone wrong with my product? How can I make zope recognise it again? I have included the top of my zIMAP.py file as well in case it is required. I'd really appreciate any help. tim top of zIMAP.py import imaplib, re, string, sys, os, DocumentTemplateimport Globalsfrom Globals import Persistent, Acquisitionimport AccessControlimport OFS class zimap (Acquisition.Implicit,Persistent,AccessControl.Role.RoleManager,OFS.SimpleItem.Item,): """zIMAP - Zope Product for displaying IMAP mailbox contents.""" index_html = DocumentTemplate.HTMLFile("zIMAP1.dtml")manage_addzIMAPForm = Globals.HTMLFile('add_zIMAP', globals()) meta_type = 'zIMAP (webmail)' def __init__(self, host):self.host = hostself.product_root = '.' class email: def connect(self, user, passw):self.user = userself.passw = passw self.M = imaplib.IMAP4(self.host)self.M.login(self.user, self.passw)self.user_dir = zimap.product_root+'/spool/'+self.useremail.makefiles(self) ...
Re: [Zope] dtml-in over the output from my method
- Original Message - From: Max M [EMAIL PROTECTED] To: Tim Hicks [EMAIL PROTECTED]; Zope@Zope. Org [EMAIL PROTECTED] Sent: Monday, November 06, 2000 9:48 PM Subject: RE: [Zope] dtml-in over the output from my method snip def list_messages(self): class msg: def __init__(self, msgnum, msgfrom, msgsub): self.msgnum = msgnum self.msgfrom = msgfrom self.msgsub = msgsub msgList = [] lr = open(self.user_dir+'/msg_list', 'r') spl = re.compile('\s\|\s') for msg_line in lr.readline(): num_from_sub = [] num_from_sub = spl.split(msg_line, 2) # Oh no ... this wont cut it! #self.msgnum = num_from_sub[0] #self.msgfrom = 'This is from UNKNOWN' #self.msgsub = 'My special subject' #return self.msgnum, self.msgfrom, self.msgsub # Do it like this: msgList.append(msg(num_from_sub[0],'This is from UNKNOWN', 'My special subject')) return msgList Brilliant, it works a treat. Thanks very much. tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Simple dtml-unless problem
- Original Message - From: "Oleg Broytmann" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, September 13, 2000 12:56 PM Subject: Re: [Zope] Simple dtml-unless problem On Wed, 13 Sep 2000, Tim Hicks wrote: dtml-unless "id == 'index_html'" Sometimes id is string, sometimes it is a function. dtml-unless "_['id'] == 'index_html'" Thanks very much guys. _['id'] fixed it. tim Oleg. Oleg Broytmannhttp://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Simple dtml-unless problem
I have the following code in my standard_html_header dtml-unless "id == 'index_html'" img src="dtml-var path/images/transparent.gif" width=400 height=12 alt="" H1 align="center"dtml-var title/h1 /dtml-unless The problem is, it displays the img and h1 stuff even when the page that the standard_html_header is being dropped into is index_html. I'm pretty sure I'm missing something really silly here, but if anyone could point it out, I'd really appreciate it. cheers tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Zclass not reindexing (it is CatalogAware)
I have created a Zclass, the the _ZClass_for_CatalogAware base class as the first added base class (second in the list of base classes). My zcatalog (named Catalog) is set to 'Find objects of type: "myClass_metatype"' and therefore, when I add a new instance of my class, it is automatically added to the catalog. By that, I mean that once I have added the instance, I can go the the 'Cataloged Objects' view and see it listed there. However, if I try a search using the raw (TextIndex) search outlined in one of the tutorials, the search fails to find words that I *know* are in the zclass that I just added, and that I thought had been cataloged. Clicking on 'Update Catalog' in the 'Cataloged Objects' view and then researching means that the search succeeds in finding the word in the new instance. The question is, do I need to add the equivalent of what is written in 'How-To: Creating a CatalogAware ZClass' for reindexing zclass properties, but for reindexing the actual text? How could I do this? extract from 'How-To: Creating a CatalogAware ZClass' dtml-call "propertysheets.InstanceConstants.manage_changeProperties(REQUEST)" dtml-call reindex_object /extract from 'How-To: Creating a CatalogAware ZClass' Help much appreciated, tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)
- Original Message - From: "Dieter Maurer" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Sent: Thursday, September 07, 2000 7:00 PM Subject: Re: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header) Hi Tim NameError: theatre_class It would seem that string is still raising its head. Any ideas? I do not think so. You get a name error: Zope does not know your "theatre_class" at this point. It seems more likely, that DC changed to way ZClasses are located inside the constructor. Take the generated ZClass constructor and simply add the "...REQUEST.set..." before the "createInObjectManager". OK, I'm so sorry about this, you've been an absolute legend so far, and I really don't want to push my luck, but each time you solve something, I find something else that has broken. This is what my theatre_class_add method looks like (well, an excerpt anyway). dtml-call "REQUEST.set('__name__', REQUEST['id'])" dtml-with "theatre_class.createInObjectManager(REQUEST['id'], REQUEST)" dtml-call "propertysheets.theatre_class_property.manage_editProperties(REQUEST)" dtml-call "manage_edit('dtml-var standard_html_header\n\ndtml-var standard_html_footer', '')" /dtml-with When I try to create a new instance of the zclass in the original 'site' folder (or any of its parent folders except for the root), I get this error. I do not receive an error and everything works fine when I create the instance in a new folder on a different 'branch' to the original. traceback Traceback (innermost last): File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 222, in publish_module File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 187, in publish (Object: testing) File C:\PROGRA~1\Zope221\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: RoleManager) File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 171, in publish (Object: testing) File C:\PROGRA~1\Zope221\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: theatre_class_add) File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: theatre_class_add) File C:\PROGRA~1\Zope221\lib\python\OFS\DTMLMethod.py, line 172, in __call__ (Object: theatre_class_add) File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_String.py, line 528, in __call__ (Object: theatre_class_add) File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_With.py, line 133, in render (Object: theatre_class.createInObjectManager(REQUEST['id'], REQUEST)) File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_Util.py, line 337, in eval (Object: theatre_class.createInObjectManager(REQUEST['id'], REQUEST)) (Info: REQUEST) File lt;stringgt;, line 0, in ? NameError: theatre_class /traceback When I try to copy and paste a zclass from this original 'site' folder (or any of its parent folders except for the root), I get this error. I do not receive an error and everything works fine when I copy and paste an instance in a new folder on a different 'branch' to the original. "One or more items referred to in the clipboard data was not found. The item may have been moved or deleted after you copied it." When I try to rename a class that is in the original 'site' folder (or any of its parent folders except for the root), I get this error. I do not receive an error and everything works fine when I rename an instance in a new folder on a different 'branch' to the original. traceback Traceback (innermost last): File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 222, in publish_module File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 187, in publish File C:\PROGRA~1\Zope221\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 171, in publish File C:\PROGRA~1\Zope221\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: manage_renameObjects) File C:\PROGRA~1\Zope221\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: manage_renameObjects) File C:\PROGRA~1\Zope221\lib\python\OFS\CopySupport.py, line 273, in manage_renameObjects (Object: Traversable) File C:\PROGRA~1\Zope221\lib\python\OFS\CopySupport.py, line 285, in manage_renameObject (Object: Traversable) File C:\PROGRA~1\Zope221\lib\python\OFS\ObjectManager.py, line 236, in _getOb (Object: Traversable) AttributeError: (see above) /traceback Like I say, you've been fantastic in helping me. Thanks to you, I now have a solution whereby I know I can redo all of the class instances I have created, and be sure that the error won't reappear. However, I'm sure from what you have said so far, there is a way around this that doesn't invo
Re: [Zope] Zclass not reindexing (it is CatalogAware)
- Original Message - From: "R. David Murray" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, September 07, 2000 10:12 PM Subject: Re: [Zope] Zclass not reindexing (it is CatalogAware) On Thu, 7 Sep 2000, Tim Hicks wrote: The question is, do I need to add the equivalent of what is written in 'How-To: Creating a CatalogAware ZClass' for reindexing zclass properties, but for reindexing the actual text? How could I do this? When is the text created? After it is, you have to call reindex_object. So each time there is a change made to the text, I must call reindex_object, is that correct? If so, how do I make it so that each time I hit the 'Change' button at the bottom of the text box, dtml-call "reindex_object()" is executed? cheers tim --RDM ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)
- Original Message - From: "Dieter Maurer" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, September 05, 2000 9:44 PM Subject: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header) snip The analysis provides a workaround for you. In your ZClass constructor, add dtml-call "REQUEST.set('__name__',REQUEST['id'])" before the dtml-with "yourClass.createInObjectManager(REQUEST['id'],REQUEST)" snip Dieter, I tried using the code that you suggested above, but I get the following error from Zope 2.2.1 snipped traceback File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_With.py, line 133, in render (Object: theatre_class.createInObjectManager(REQUEST['id'], REQUEST)) File C:\PROGRA~1\Zope221\lib\python\DocumentTemplate\DT_Util.py, line 337, in eval (Object: theatre_class.createInObjectManager(REQUEST['id'], REQUEST)) (Info: REQUEST) File lt;stringgt;, line 0, in ? NameError: theatre_class It would seem that string is still raising its head. Any ideas? tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header)
- Original Message - From: "Dieter Maurer" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, September 05, 2000 9:44 PM Subject: ZClass Bug (was: Re: [Zope] How to access id and title of document calling standard_html_header) Tim Hicks writes: OK, I think that I am perhaps misusing zclasses then. Here is what I have. No you did not. That's a relief. I have a Folder that was created by using the 'Add new item' menu within Zope. This folder is called 'Site'. I have a Zclass called 'theatre_class' that has "Base classes ZObject, _ZClass_for_CatalogAware, _ZClass_for_DTMLDocument" Within the Folder 'Site', I have standard_html_header dtml-method ... However, if I try to put dtml-var id into the standard_html_header, I get nothing... I analysed your problem (in Zope 2.1.6). It is *NOT* a problem of "standard_html_header". Instead, it is a ZCLass problem. OK. The id of a ZInstance created as you described it returns "string". The browser shows this as "empty" because it is a tag it does not understand and therefore ignores. You see it, though, when you look at the HTML source. Yup, I'm with you on that. The reason for this strange id lies in a mismatch between your ZClass, more precisely its __init__ method, and the content of REQUEST: For some reason, your ZClass uses "DocumentTemplate.DT_String.__init__" as constructor. "DocumentTemplate.DT_String" defines a "id" function and lets it return the value of the "__init__" parameter "__name__". The default for "__name__" is, you guess it, "'string'". You are losing me a bit with the "__init__", "DocumentTemplate.DT_String" and "__name__" (I'm afraid my Python is limited, to say the least!). I do see the results of string being the default value though ;-). "ZClass.createInObjectManager" constructs the ZInstance. If the instance has a 'id', it takes this id and ignores the 'id' passed as parameter. Thus, you get a ZInstance with this strange id. I think I'm with you there. I am convinced, this is a ZClass bug. I think, that the bug results from the fact, that the constructor for a ZCLass deriving from DTML Document used "__name__" as "id" replacement. The analysis provides a workaround for you. In your ZClass constructor, add dtml-call "REQUEST.set('__name__',REQUEST['id'])" before the dtml-with "yourClass.createInObjectManager(REQUEST['id'],REQUEST)" Great. I presume that this will only work for all *new* instances of this class however! I don't suppose you know of a way of remaking all 44 instances of this Zclass I have using this adjusted constructor? I have tried (see below), but I think I come up against the same 'string' problem that I'm actually trying to counteract! dtml-in Catalog dtml-call "REQUEST.set('sequence-item',REQUEST['id'])" dtml-with "theatre_class.createInObjectManager(REQUEST['id'], REQUEST)" dtml-call "propertysheets.theatre_class_property.manage_editProperties(REQUEST)" dtml-call "manage_edit(REQUEST)" /dtml-with /dtml-in Anyway, I guess this is a different problem again really isn't it? I think for now, it will be easier to use my less elegant workaround of giving the zclass another property called 'counter_id' * that is the same as the actual id. I know that this works, and it won't take as long as remaking all the instances again... I don't have the strength for that I don't think. I'll definitely file away your fix for future reference though. Thanks very much. Now, after I did some work for you, I have some tasks for you: * check, whether the bug is in Zope 2.2.1, too Yes, it does. I have now found this to occur in 2.1.6, 2.2.0 and 2.2.1. * if this turns out to be the case, file a bug report into the collector. Right, I have done that, hopefully satisfactorily! Hope you don't mind, I used 'extensive' quotes from your reply... no point in using my words to confuse the issue! Thanks very much Dieter, you've been a MASSIVE help. tim Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] How to access id and title of document calling standard_html_header
For those of you who saw my posts from a couple of days ago (Dieter Maurer and Geir Bfkholt), this is the question that I think I should have been asking in the first place. I have a standard_html_header that is inserted into Zclasses. These Zclasses have properties including meta_author, meta_description etc (I don't think it is important what they are, just that they are properties that standard_html_header does not have). In the standard_html_header, I use code such as dtml-var meta_author and dtml-var meta_description. This works fine and the properties of the *zclass* are inserted. However, if I put dtml-var id into the standard_html_header, I get the id of standard_html_header, *not* of the zclass. How do I tell zope to which item I am refering (bearing in mind, I don't know the name of the zclass ie it is variable)? Cheers tim ps. As a workaround, I have simply given my zclasses an alternative property (counter_id) that I make the same as the real id, but this seems to be a clumsy way of doing it. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] How to access id and title of document calling standard_html_header
For those of you who saw my posts from a couple of days ago (Dieter Maurer and Geir Bfkholt), this is the question that I think I should have been asking in the first place. I have a standard_html_header that is inserted into Zclasses. These Zclasses have properties including meta_author, meta_description etc (I don't think it is important what they are, just that they are properties that standard_html_header does not have). In the standard_html_header, I use code such as dtml-var meta_author and dtml-var meta_description. This works fine and the properties of the *zclass* are inserted. However, if I put dtml-var id into the standard_html_header, I get the id of standard_html_header, *not* of the zclass. How do I tell zope to which item I am refering (bearing in mind, I don't know the name of the zclass ie it is variable)? Cheers tim ps. As a workaround, I have simply given my zclasses an alternative property (counter_id) that I make the same as the real id, but this seems to be a clumsy way of doing it. ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to access id and title of document calling standard_html_header
- Original Message - From: "Kapil Thangavelu" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Saturday, September 02, 2000 3:59 PM Subject: Re: [Zope] How to access id and title of document calling standard_html_header Tim Hicks wrote: For those of you who saw my posts from a couple of days ago (Dieter Maurer and Geir Bfkholt), this is the question that I think I should have been asking in the first place. I have a standard_html_header that is inserted into Zclasses. These Zclasses have properties including meta_author, meta_description etc (I don't think it is important what they are, just that they are properties that standard_html_header does not have). In the standard_html_header, I use code such as dtml-var meta_author and dtml-var meta_description. This works fine and the properties of the *zclass* are inserted. However, if I put dtml-var id into the standard_html_header, I get the id of standard_html_header, *not* of the zclass. How do I tell zope to which item I am refering (bearing in mind, I don't know the name of the zclass ie it is variable)? Cheers Make your standard_html_header a DTML Method not a Document. Methods operate on their containers. Documents operate on themselves. The Document is acquiring the ZClass properties after looking through its own. The Method looks for the properties of its containers. Kapil It is a method already! Any ideas. If it makes any difference, I'm running Zope 2.2.0 (although I really don't think this is important). tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] dtml-with and PARENTS[0]
OK, I have a standard_html_header for my site that uses the following dtml-with "PARENTS[0]" titledtml-var head_title/title META NAME="keywords" CONTENT="dtml-var meta_keywords" META NAME="description" CONTENT="dtml-var meta_description" META NAME="author" CONTENT="dtml-var meta_author" META NAME="copyright" CONTENT="dtml-var meta_copyright" dtml-var head_javascript snipped rest of document dtml-var id /dtml-with In this way, the properties of the ZClass (into which the standard_html_header is placed) are used for the for the meta author/copyright/keywords/description/javascript. All of those that I just mentioned work perfectly well, with the correct property being inserted, however, dtml-var id results in the id of the parent folder of standard_html_header being inserted, instead of the id of the zclass. Could anyone point out how I can get hold of the zclass id? thanks very much tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] dtml-with and PARENTS[0]
- Original Message - From: "Geir Bfkholt" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 31, 2000 2:30 PM Subject: Re: [Zope] dtml-with and PARENTS[0] on Thursday, August 31, 2000 Tim Hicks wrote : TH OK, I have a standard_html_header for my site that uses the following [snip] THwith the correct property being TH inserted, however, dtml-var id results in the id of the parent TH folder of standard_html_header being inserted, instead of the id of TH the zclass. Could anyone point out how I can get hold of the zclass TH id? first of all : make sure your standard_html_header is a method, not a document Yup, definitely a method. Out of interest, if it were a document, why would all of the dtml-var's work except id? tim -- Geir Bækholt web-developer/designer [EMAIL PROTECTED] http://www.funcom.com ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: Re[2]: [Zope] dtml-with and PARENTS[0]
- Original Message - From: "Geir Bfkholt" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 31, 2000 2:56 PM Subject: Re[2]: [Zope] dtml-with and PARENTS[0] on Thursday, August 31, 2000 Tim Hicks wrote : TH Yup, definitely a method. Out of interest, if it were a document, why TH would all of the dtml-var's work except id? acquisition, i guess.. satandard_html_header would not usually have those properties itself.. if it was a document, and had those other properties, the ones from the header would be used.. Seems rather strange that id from standard_html_header is used if it is a method.. puzzling.. cannot think of a reason.. DOH! There was me thinking that I had to use PARENTS[0] in order to get hold of the zclas that had standard_html_header inserted into it... when I don't! Taken out all the PARENTS[0]'s and it is behaving like it should do. Now it's working, I think I actually understand how it works as well! Sorry about that, I think I made things more complicated than they are. tim -- Geir Bækholt web-developer/designer [EMAIL PROTECTED] http://www.funcom.com ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Nested dtml???
- Original Message - From: "Dieter Maurer" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Cc: "zope" [EMAIL PROTECTED] Sent: Tuesday, August 29, 2000 11:10 PM Subject: Re: [Zope] Nested dtml??? Tim Hicks writes: I am trying to work my way up through folders, checking whether each folder has a property named 'site_root_folder'. Logically (in *my* head anyway), what I have written below is what I want to do, but I'm not sure that I'm really writing this the write way. I vaguely remember reading that I can't nest dtml-if tags within dtml-in tags. There is no problem whatsoever to use "dtml-if" inside "dtml-in". dtml-let level=0 dtml-in level dtml-if "PARENTS[level].hasProperty('site_root_folder')" dtml-var "PARENTS[level].absolute_url()" dtml-else level="level+1" /dtml-in /dtml-let "dtml-in" works with sequences. In your example, however, you give it an integer ("level"). It will not be happy with this. You may try: dtml-in PARENTS dtml-let PARENT="_.getitem('sequence-item')" dtml-if "PARENT.hasProperty Excellent. Here is what I have managed to make work. dtml-in PARENTS dtml-let PARENT="_.getitem('sequence-item')" dtml-if "PARENT.hasProperty('site_root_folder')"dtml-var "PARENT.absolute_url()"/dtml-if /dtml-let /dtml-in I really appreciate it. And thanks for the reply on my other (related) post. Don't think I'll mess with ZopeFind for now; I don't always have access to Zope 2.2.x, but more usually 2.1.6. Thanks again. tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Nested dtml???
- Original Message - From: "Curtis Maloney" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED]; "zope" [EMAIL PROTECTED] Sent: Wednesday, August 30, 2000 12:24 AM Subject: Re: [Zope] Nested dtml??? On Tue, 29 Aug 2000, Tim Hicks wrote: I am trying to work my way up through folders, checking whether each folder has a property named 'site_root_folder'. Logically (in *my* head anyway), what I have written below is what I want to do, but I'm not sure that I'm really writing this the write way. I vaguely remember reading that I can't nest dtml-if tags within dtml-in tags. I'd really appreciate any help on this tim dtml-let level=0 dtml-in level dtml-if "PARENTS[level].hasProperty('site_root_folder')" dtml-var "PARENTS[level].absolute_url()" dtml-else level="level+1" /dtml-in /dtml-let Hmm.. it may be slower, but I would normally use a recursive function in this case. DTML Method findRoot dtml-if "PARENTS[rootLevel].hasProperty('site_root_folder')" dtml-return PARENTS[rootLevel].absolute_url()" dtml-else dtml-return "findRoot(_.None, _, rootLevel=rootLevel+1)" /dtml-if Use as: dtml-var "findRoot(_.None, _, rootLevel=0)" Thanks for the ideas, but I have managed to do what I wanted to do using the code below (with help from Dieter Maurer). dtml-in PARENTS dtml-let PARENT="_.getitem('sequence-item')" dtml-if "PARENT.hasProperty('site_root_folder')"dtml-var "PARENT.absolute_url()"/dtml-if /dtml-let /dtml-in Tim: [EMAIL PROTECTED] If you don't mind my asking, why do you need to hunt down this folder? Is there no way Acquisition could be used to simplify your life? I have made a couple of 'sites' that need to be portable so that they can be placed on any server, with their 'root' directory having any name without needing to edit anything. Therefore, in every link/URL within the site, I do something like the following, href="dtml-var path/link/to/whatever.html" The path method is what contains the code that I have shown above. In this way, all the links work no matter what server they are placed on (zope of course!). I don't think I could have just used relative links as my standard_html_header/footer contains links/images. With relative links, when the header/footer was placed into a document that was not in the site's root folder, they were broken. Does that make any sense? Have I gone about it a bit backwards? Anyway, you did ask :-) tim Have a better one, Curtis ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] Nested dtml???
I am trying to work my way up through folders, checking whether each folder has a property named 'site_root_folder'. Logically (in *my* head anyway), what I have written below is what I want to do, but I'm not sure that I'm really writing this the write way. I vaguely remember reading that I can't nest dtml-if tags within dtml-in tags. I'd really appreciate any help on this tim dtml-let level=0 dtml-in level dtml-if "PARENTS[level].hasProperty('site_root_folder')" dtml-var "PARENTS[level].absolute_url()" dtml-else level="level+1" /dtml-in /dtml-let Tim: [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] How to get URL of folder (name unknown) with a certain property?
I am trying to figure out how to get hold of the URL (using absolute_url I presume) of a folder with a property called "sehs_root_folder" set to "yes". I do not know what the name of this folder is, so I am finding it difficult to use the hasattr function, and I don't have any way of knowing where abouts in the document tree the folder is (except that it must be a 'parent' folder of the one that contains the dtml-method that I am running the code from). Does that make any sense? I'm finding it difficult to even express my question, so searching the mailing list archives is proving fruitless. I'd appreciate any pointers tim ps. The reason I'm trying to do this is to make my site more portable. I would like to be able to change servers and/or folder names on my server without damaging all the links and addresses to images/files on the site. As such, everywhere that I have any sort of link/address on the site, I currently use the following: dtml-var path/address/to/whatever/ dtml-var path is a method that resides in the 'root' folder of the site, and in it, I put the current appropriate path for the site. However, I would like to make this method automatically figure out the appropriate path. Therefore, I gave the 'root folder' a property called "sehs_root_folder" that I hope to search for. If you have a more efficient way of solving my problem, please let me know. Tim: [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Zope] dtml-if errors in sql method
dtml-if "which_table == 'Plays'" SELECT * FROM dtml-var which_table WHERE "Play title" like dtml-sqlvar "'%'+_.string.strip(form_string)+'%'" type=string; Can anybody explain to me what is going on with my zsql method? Zope gives me the following error when I try and change my method to what is above. Invalid attribute name, "which_table", for tag dtml-if "which_table == 'Plays'", on line 16 of string I've scoured the mailing list, but I'm still mightily confused. which_table is one of the arguments for the the sql method and Plays is a string that I want to compare it with. which_table comes from a form elsewhere. I'm sure it's something really simple, and I'm sure it's been discussed here before (at length?), but ATM, I don't even know what I'm looking for! Thanks for the help tim ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] dtml-if errors in sql method
- Original Message - From: "Gregory Haley" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Sent: Tuesday, July 18, 2000 7:35 PM Subject: Re: [Zope] dtml-if errors in sql method Hi, Are you searching for the exact word "Plays", or is there a variable called Plays against which you are trying to match a value? If it's the latter, having the single quotes is teling it to search for the literal. If you are setting the value of plays in a higher call, eg. dtml-call "REQUEST.set('Plays', Play_titles)", your if expression would need to be "which_table == Plays". Hope this is helpful, as it is a mistake I am always making! ciao! greg. Gregory Haley venaca.com Thanks for that... I am trying to compare which_table to the exact string Plays. Plays is not a variable/argument/integer//whatever, I am just trying to see if the string that is returned from one of the fields of my form (which_table) is equal to the string Plays. snip Tim: [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] dtml-if errors in sql method
- Original Message - From: "Dieter Maurer" [EMAIL PROTECTED] To: "Tim Hicks" [EMAIL PROTECTED] Sent: Tuesday, July 18, 2000 9:51 PM Subject: Re: [Zope] dtml-if errors in sql method Tim Hicks writes: dtml-if "which_table == 'Plays'" SELECT * FROM dtml-var which_table WHERE "Play title" like dtml-sqlvar "'%'+_.string.strip(form_string)+'%'" type=string; Can anybody explain to me what is going on with my zsql method? Zope gives me the following error when I try and change my method to what is above. Invalid attribute name, "which_table", for tag dtml-if "which_table == 'Plays'", on line 16 of string The error message looks strange. It seems that the parser does not see the "...", because "which_table" actually is not an attribute at all. Did you declare "which_table" as argument of the Z SQL method. This will probably not remove your current problem but may later come up. Dieter Yes, which_table and form_string are both declared as arguments in the zsql method. Tim: [EMAIL PROTECTED] ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )