Modifizieren eines ATDocuments vor dem Rendern

6 messages Options
Embed this post
Permalink
Robert Barsch

Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
Hallo Liste,

ich möchte gerne in Plone 3 vor dem Rendern einer Page (ATDocument) den
von Plone generierten HTML Output des Body Textes modifizieren können.


In Plone 2.1 geht sowas via Monkey Patch:

> from Products.ATContentTypes.types.ATDocument import ATDocument
>
> def CookedBody(self, stx_level=None, setlevel=0):
>     text = self.getText()
>     # do someting with the text
>     text = text.upper()
>     return text
>
> ATDocument.CookedBody = CookedBody


Wie würde ich sowas machen ohne Einführung eines neuen ContentTypes und
auf möglichst eleganter Art & Weise mit Zope 3 Techniken?

LG,
Robert




_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope
ajung

Re: Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
On 16.05.09 13:54, Robert Barsch wrote:

> Hallo Liste,
>
> ich möchte gerne in Plone 3 vor dem Rendern einer Page (ATDocument) den
> von Plone generierten HTML Output des Body Textes modifizieren können.
>
>
> In Plone 2.1 geht sowas via Monkey Patch:
>
>  
>> from Products.ATContentTypes.types.ATDocument import ATDocument
>>
>> def CookedBody(self, stx_level=None, setlevel=0):
>>     text = self.getText()
>>     # do someting with the text
>>     text = text.upper()
>>     return text
>>
>> ATDocument.CookedBody = CookedBody
>>    
>
> Wie würde ich sowas machen ohne Einführung eines neuen ContentTypes und
> auf möglichst eleganter Art & Weise mit Zope 3 Techniken?
Monkeypatching ist "good enough". Zope 3 Techniken helfen Dir hier auch
nicht viel weiter.

Andreas

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard





_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope
Robert Barsch-2

Re: Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,

hmm mit ATDocument.CookedBody kann ich in Plone 3 wohl nicht mehr dafür
nutzen - welche Methode ich den dann "gefahrlos" patchen?

Danke,
Robert

>> ich möchte gerne in Plone 3 vor dem Rendern einer Page (ATDocument) den
>> von Plone generierten HTML Output des Body Textes modifizieren können.
>>
>> In Plone 2.1 geht sowas via Monkey Patch:
>>
>>> from Products.ATContentTypes.types.ATDocument import ATDocument
>>>
>>> def CookedBody(self, stx_level=None, setlevel=0):
>>>     text = self.getText()
>>>     # do someting with the text
>>>     text = text.upper()
>>>     return text
>>>
>>> ATDocument.CookedBody = CookedBody
>>>    
>> Wie würde ich sowas machen ohne Einführung eines neuen ContentTypes und
>> auf möglichst eleganter Art & Weise mit Zope 3 Techniken?
> Monkeypatching ist "good enough". Zope 3 Techniken helfen Dir hier auch
> nicht viel weiter.
>
> Andreas
>
>
> ------------------------------------------------------------------------
>
>
>
> _______________________________________________
> zope mailing list
> [hidden email]
> https://mail.dzug.org/mailman/listinfo/zope


- --

Dipl.-Geophys. Robert Barsch
Department für Geo- und Umweltwissenschaften
Geophysik
Ludwig-Maximilians-Universität
Theresienstrasse 41
80333 München
Deutschland

Tel: +49 (0) 89 2180 4201
Fax: +49 (0) 89 2180 4205
Mail: [hidden email]


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKGTBSIVowwEY4LjQRAhfbAKDiPq3CidpB7WF8Q9eXQydIelzsOQCeIsRE
LEwETOrAQgybgbMkKfWtpf4=
=1+OX
-----END PGP SIGNATURE-----


_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope
Robert Barsch-2

Re: Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

args - nochmal aber diesmal in Deutsch ;)

hmm ATDocument.CookedBody ist in Plone 3 wohl nicht mehr dafür
nutzbar - welche Methode kann ich den dann dafür "gefahrlos" patchen?

Danke,
Robert

>> ich möchte gerne in Plone 3 vor dem Rendern einer Page (ATDocument) den
>> von Plone generierten HTML Output des Body Textes modifizieren können.
>>
>> In Plone 2.1 geht sowas via Monkey Patch:
>>
>>> from Products.ATContentTypes.types.ATDocument import ATDocument
>>>
>>> def CookedBody(self, stx_level=None, setlevel=0):
>>>     text = self.getText()
>>>     # do someting with the text
>>>     text = text.upper()
>>>     return text
>>>
>>> ATDocument.CookedBody = CookedBody
>>>    
>> Wie würde ich sowas machen ohne Einführung eines neuen ContentTypes und
>> auf möglichst eleganter Art & Weise mit Zope 3 Techniken?

> Monkeypatching ist "good enough". Zope 3 Techniken helfen Dir hier auch
> nicht viel weiter.
>
> Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKGTJ5IVowwEY4LjQRAo/DAJ0e9mMd22+WmD4S2SbcUypFJUnleACg05wa
vgve9Q5SxZuJRT3qSi5MBmY=
=FZSw
-----END PGP SIGNATURE-----


_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope
ajung

Re: Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
On 24.05.09 13:41, Robert Barsch wrote:
> args - nochmal aber diesmal in Deutsch ;)
>
> hmm ATDocument.CookedBody ist in Plone 3 wohl nicht mehr dafür
> nutzbar -

Warum nicht?

> welche Methode kann ich den dann dafür "gefahrlos" patchen?

ggf. kannst Du via archetypes.schemaextender (oder auch via Monkeypatching)
die Accessor Methode für 'body' auf eine eigene Methode umbiegen.
Die eigene Methode kannst Du auch via Monkeypatching "dran flanschen" oder
ggf. über dm.reuse().

Andreas

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard





_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope
Robert Barsch-2

Re: Modifizieren eines ATDocuments vor dem Rendern

Reply Threaded More More options
Print post
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Jung schrieb:
> On 24.05.09 13:41, Robert Barsch wrote:
>>
>> hmm ATDocument.CookedBody ist in Plone 3 wohl nicht mehr dafür
>> nutzbar -
>
> Warum nicht?

Plone 3.2.2
__init__.py des Produktes

> from Products.ATContentTypes.content.document import ATDocument
> import logging
>
> logger=logging.getLogger("Plone")
>
> def myCookedBody(self, **kwargs):
>     logger.info("JUHU!")
>     text = self.getText()
>     text = 'muh' + text
>     return text
>
> ATDocument.CookedBody = myCookedBody
> logger.info("Patch applied")


"Patch applied" taucht beim Startup in den Logs auf - "JUHU!" bekomme
ich dagegen nicht, egal was ich tue ...

Übersehe ich irgendwas?

>> welche Methode kann ich den dann dafür "gefahrlos" patchen?
>
> ggf. kannst Du via archetypes.schemaextender (oder auch via Monkeypatching)
> die Accessor Methode für 'body' auf eine eigene Methode umbiegen.
> Die eigene Methode kannst Du auch via Monkeypatching "dran flanschen" oder
> ggf. über dm.reuse().

mit schemaextender hatte ich es schon mal (leider erfolglos) probiert -
aber dabei den Accessor umzubiegen ist eine Idee - mal schauen wie weit
ich komme

Gruß + Dank,
Robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKGdsmIVowwEY4LjQRAhAbAKDk9So0o8IvnLXT4b8m5JOM/V67QgCdEAgh
UYMgfWrL6e2e1LEyL4XjYb4=
=0CK5
-----END PGP SIGNATURE-----


_______________________________________________
zope mailing list
[hidden email]
https://mail.dzug.org/mailman/listinfo/zope