Re: Python: "dynamische" Klassenvariablen?

Andreas Jung <[email protected]>
Newsgroups gmane.comp.web.zope.german
Organization ZOPYX Ltd & Co. KG
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Zechmeister wrote:
> Hallo,
>
> ich schreibe gerade an einem Produkt für Zope. Es hat einige ZPTs,
> die ich im Products/zpt-Verzeichnis haben möchte und beim Erstellen
> einer Instanz _nicht_ in der ZODB haben will. Ich denke, das würde
> in etwa so gehen:
>
> class TestClass(Implicit, Persistent, RoleManager, Item): [...]
> zptA=PageTemplateFile('zpt/zptA.htm', globals())
> zptB=PageTemplateFile('zpt/zptB.htm', globals())
> zptC=PageTemplateFile('zpt/zptC.htm', globals()) [...]
>
Mach es bitte so :-)

Oder mach mach aus 26 Templates (A-Z?) eines und steck mehr Logik
in das Template.

Andreas


> Diese ZPTs landen dann genauso im Namespace von context, als würden
> sie im ZMI liegen und sie sind immer aktuell - zumindest nach
> jedem Zope-Neustart.
>
> Nur ist es etwas mühsam, für jedes ZPT eine eigene Zeile zu haben.
> Jetzt suche ich nach einer Möglichkeit, mit einem Rutsch alle Files
> aus Products/zpt/* in die Klasse zu bekommen. Wie würde das gehen
> (also das 'dynamische' Anlegen von Klassenvariablen, die
> Filesystem-Sachen sind mir eh klar)?
>
> Hab mir schon überlegt, das im __init__ zu machen und dann jeweils
> self[scriptname] = PageTemplateFile(...) zu machen. Aber wenn ich
> das richtig verstehe, hätte ich die ZPTs dann in jeder Instanz
> persistent drinnen und somit Probleme mit der Versionierung.
>
> BGrü PeterZ
>
>
> ----------------------------------------------------------------------
>
>
>
>
>
_______________________________________________
> zope mailing list [email protected]
> https://mail.dzug.org/mailman/listinfo/zope


- -- 
ZOPYX Limited              \ zopyx group
Charlottenstr. 37/1         \ The full-service network for your
D-72070 Tübingen             \ Python, Zope and Plone projects
www.zopyx.com, [email protected] \ www.zopyxgroup.com
- ------------------------------------------------------------------------
E-Publishing, Python, Zope & Plone development, Consulting


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

iEYEARECAAYFAktpnMoACgkQCJIWIbr9KYz4vQCePSMQbocbecLLEi1doxP6sZeV
B4AAoM7a+wqvNf/OmXpji5kpEE4raN6b
=sN+Z
-----END PGP SIGNATURE-----



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
lists.vcf (text/x-vcard, 331 B)
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:[email protected]
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.