Re: [Zope-dev] Help needed: why is this DTML not working in zope 2 ?
You could try moving stuff to the new dtml style for starters: dtml-var standard_html_header and the like. That might help, if not let us know.. cheers, Chris Gilles Lavaux wrote: Hello, I am a little bit disappointed not getting any echo from my previous question, so I report it. Maybe my dtml is wrong for zope2, but I would appreciate to have some explanation from more experienced peoples. If I can not find a solution, we will have to keep our zope1 production server, and it will be the end of the Zope story in my company :-( So my question was : I want to display the content of a site starting from a folder called 'Site' with a tree tag. I want also to render immediately inside the tree the documents with an ID=='PUBLIC_Doc'. In Zope 1.x I have a working dtml method like this: !--#var standard_html_header-- !--#tree Site branches_expr="objectValues()" sort=id skip_unauthorized-- b!--#var id--/b !--#if "_['id']=='PUBLIC_Doc'"-- ## !--#try-- !--#var "_[_['id']]"-- !--#except-- !--#var Except_Message-- !--#/try-- ## !--#/if-- !--#/tree-- !--#var standard_html_footer-- Unfortunatly for me , with zope 2.1.6 i get an error when I try to render the 'PUBLIC_Doc' document: . PUBLIC_Doc !# Error type:AttributeError Error Message: Error Message:__call__ Error TB:Traceback (innermost last): File "/usr/lib/python1.5/site-packages/DocumentTemplate/DT_Try.py", line 221, in render_try_except result = render_blocks(self.section, md) File "/usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py", line 335, in eval return eval(code,globals,d) File "", line 0, in ? File "/usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py", line 161, in careful_getitem v=mapping[key] File "/usr/share/zope/lib/python/OFS/DTMLMethod.py", line 146, in __call__ r=apply(HTML.__call__, (self, client, REQUEST), kw) File "/usr/lib/python1.5/site-packages/DocumentTemplate/DT_String.py", line 502, in __call__ try: return render_blocks(self._v_blocks, md) AttributeError: __call__ has someone a solution ?? Thanks, Gilles ___ 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 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] Help needed: why is this DTML not working in zope 2 ?
Hello Lee !--#var PUBLIC_Doc-- doesn't change anything, same error. (you are right, I can use the name directly , but I have some other piece of code where I have to use the _[_['']] construction, so it has to work...) But I found something: In my 'PUBLIC_Doc' document I display image with a !--# var image_name-- tag, my problem disappear if I use !--#var "image_name"--, someone can explain this?? Thanks anyway for the replies Gilles -Original Message- From: LEE, Kwan Soo [EMAIL PROTECTED] To: Gilles Lavaux [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, July 04, 2000 12:32 PM Subject: Re: [Zope-dev] Help needed: why is this DTML not working in zope 2 ? Not an answer, but a question. b!--#var id--/b !--#if "_['id']=='PUBLIC_Doc'"-- ## !--#try-- !--#var "_[_['id']]"-- !--#except-- You seems to "call" PUBLIC_Doc, then why don't you just !--#var PUBLIC_Doc-- instead of the !--#var "_[_['id']]"--? LEE Kwan Soo ___ 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 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] Help needed: why is this DTML not working in zope 2 ?
Gilles Lavaux wrote: But I found something: In my 'PUBLIC_Doc' document I display image with a !--# var image_name-- tag, my problem disappear if I use !--#var "image_name"--, someone can explain this?? Are you sure the space after the # isn't your problem? I would STRONGLY recommend moving your code to the new syntax, especially if you are having problems. You should be aware that plans are afoot to remove the old syntax... cheers, Chris ___ 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] Help needed: why is this DTML not working in zope 2 ?
Argh!!! no, I made a typo error : it was !--#var image_name--.the syntax was good. Ok, I will use the new syntax in my new sites. But for my old site, I will not modify my ~500 dtml methods, except if there is a way to automate the change. Gilles -Original Message- From: Chris Withers [EMAIL PROTECTED] To: Gilles Lavaux [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, July 04, 2000 1:33 PM Subject: Re: [Zope-dev] Help needed: why is this DTML not working in zope 2 ? Gilles Lavaux wrote: But I found something: In my 'PUBLIC_Doc' document I display image with a !--# var image_name-- tag, my problem disappear if I use !--#var "image_name"--, someone can explain this?? Are you sure the space after the # isn't your problem? I would STRONGLY recommend moving your code to the new syntax, especially if you are having problems. You should be aware that plans are afoot to remove the old syntax... cheers, Chris ___ 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 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] Help needed: why is this DTML not working in zope 2 ?
Steve Alexander wrote: Gilles Lavaux wrote: Argh!!! no, I made a typo error : it was !--#var image_name--.the syntax was good. Ok, I will use the new syntax in my new sites. But for my old site, I will not modify my ~500 dtml methods, except if there is a way to automate the change. You can write a pretty simple external method to walk your Zope object heirarchy looking for DTML Methods and DTML documents, then altering the syntax. Shouldn't take more than an hour to write and debug and test and document, if you've written stuff in Python before. I'm off to a meeting for a few hours, but harrass me later and I'll send to the list a proof-of-concept external method to get you started. An external method for automated change from old syntax to new syntax follows. * Use at your own risk * No warranty implied or given * Use on a copy of your main Zope site * Back up data.fs three times before starting * Not guarenteed not to spin your processor and never terminate * Run on a copy of Zope in debug mode (-D) to see the print statements * Barely tested, if at all import re def convert_dtml(self): """Convert DTML Methods and DTML Documents from old syntax to new syntax. Warning: recursive! Might just eat all your stack. Does not work on subclasses of DTML Method and DTML Document. Preserves normal comments, and handles instances of "--" in quotes. """ 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) -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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] Help needed: why is this DTML not working in zope 2 ?
Steve Alexander wrote: An external method for automated change from old syntax to new syntax follows. * Use at your own risk * No warranty implied or given * Use on a copy of your main Zope site * Back up data.fs three times before starting * Not guarenteed not to spin your processor and never terminate * Run on a copy of Zope in debug mode (-D) to see the print statements * Barely tested, if at all _convert_regex = re.compile('!--#(/?)(([^"-]+?|"[^"]*?"|-[^-])+?)--') Actually, I missed something in the original regex, above. (Funny how I noticed just after I pressed the 'send' button!) It should read like this: _convert_regex = re.compile('''!--#(/?)(([^"-]+?|"[^"]*?"|'[^']*?'|-[^-])+?)--''') The whole thing again -- same disclaimers apply, only more so :-) 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) -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ 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 )