Re: [Zope] HTML post processing in Zope
Dne čtvrtek, 5. května 2005 04:58 Cyrille Bonnet <[EMAIL PROTECTED]> napsal(a): > Hi all, > > I am trying to perform a post-processing on all HTTP responses, before > they get sent to the browsers. I am using Zope 2.7.3 nad Plone 2.0.5. > > I had a look at the ZServer class: it seems to be the right place, but I > don't understand all the code there and I am afraid to break something :-( > > Am I on the right tracks there? Could someone with great Zope knowledge > be kind enough to point out which method I should change? (I want to > change the HTML content, not the headers). I have unitws product (from somebody else) which does modifications on the resulted html code. It is able to do any modifications, I was modify them to do wml compliant national characters and more. You call it simple with your content here Place this file __init__.py into "unitws" folder of your Products: # cat /var/zope/lib/python/Products/unitws/__init__.py from string import split, strip, join, find import DocumentTemplate.DT_Util from DocumentTemplate.DT_String import String class UnitWhitespaceTag: """ Removes redundant whitespace (not very conservatively) """ name='unitws' blockContinuations=() def __init__(self, blocks): tname, args, section = blocks[0] args = DocumentTemplate.DT_Util.parse_params(args) self.blocks = section.blocks def render(self,md): a = [] for line in split(DocumentTemplate.DT_Util.render_blocks(self.blocks, md),'\n'): line = strip(line) if line: b = [] for word in split(line,' '): if word!='': b.append(strip(word)) a.append(join(b,' ')) return join(a,'\n') __call__=render String.commands['unitws']=UnitWhitespaceTag -- Jaroslav Lukesh --- This e-mail can not contain any viruses because I use Linux ___ 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] HTML post processing in Zope
Cyrille Bonnet wrote at 2005-5-5 14:58 +1200: >I am trying to perform a post-processing on all HTTP responses, before >they get sent to the browsers. I am using Zope 2.7.3 nad Plone 2.0.5. > >I had a look at the ZServer class: it seems to be the right place, but I >don't understand all the code there and I am afraid to break something :-( I think "ZPublisher.HTTPResponse.HTTPResponse" is the better place for tidying up. -- Dieter ___ 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] HTML post processing in Zope
Am Donnerstag, den 05.05.2005, 14:58 +1200 schrieb Cyrille Bonnet: > Hi all, > > I am trying to perform a post-processing on all HTTP responses, before > they get sent to the browsers. I am using Zope 2.7.3 nad Plone 2.0.5. > > I had a look at the ZServer class: it seems to be the right place, but I > don't understand all the code there and I am afraid to break something :-( > > Am I on the right tracks there? Could someone with great Zope knowledge > be kind enough to point out which method I should change? (I want to > change the HTML content, not the headers). I wonder what kind of post processing do you want? Since Zope creates all responses anyway, so why not creating the responses you want in the first place? ___ 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] HTML post processing in Zope
Cyrille Bonnet wrote: Hi all, I am trying to perform a post-processing on all HTTP responses, before they get sent to the browsers. I am using Zope 2.7.3 nad Plone 2.0.5. I had a look at the ZServer class: it seems to be the right place, but I don't understand all the code there and I am afraid to break something :-( Am I on the right tracks there? Could someone with great Zope knowledge be kind enough to point out which method I should change? (I want to change the HTML content, not the headers). Any pointer would be appreciated. I would recommend getting Apache or something like it to act as a proxy and do the rewriting there. That would likely be much cleaner than futzing with ZServer. Though I can't say exactly how this would be done. But, yes, that's probably the right place to go. I believe, based on a very quick look at the code, that continue_request in lib/python/ZServer/HTTPServer.py is probably the last place to get a hold of the response before it's sent. --jcc -- http://plonebook.packtpub.com/ ___ 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 )