metal:Macro mit optionalen Parametern?

Hartmut Goebel <[email protected]>
Newsgroups gmane.comp.web.zope.german
Organization Goebel Consult
Message-ID <[email protected]>
Am 11.03.2010 19:15, schrieb Andreas Jung:

>> <div class="zettel" tal:define="object nocall:object |
>> nocall:here;
> Sorry aber das ist frickliger Code. Mach hier bitte explizite Checks
> 
> python: object is None
> 
> oder so ähnlich rein - aber niemals via nocall:

Lasen wir mal außen vor, dass der Name 'object' ungeschickt gewählt ist ;-)

Ja, mir gefällt das auch nicht wirklich. Aber ich habe noch keine andere
Lösung gefunden, wie ich optionale Parameter an ein metal:macro
übergeben kann. Also dieses hier in METAL:

   def view_macro(object=None):
      if object is None:
         object = here

Der Code stammt aus einem metal:macro, das Teil von teaser_view.pt ist.
teaser_view.pt implementiert die document_view für Teaser, quasi als
Vorschau im Hauptteil der Seite.

Das Makro verwende ich dann, um die Teaser in einem Portlet anzuzeigen:

<div ... tal:repeat="ref refs"> <!-- refs sind die gefundenen Teaser -->
      <div tal:define="object nocall:ref"
           tal:omit-tag="">
        <div metal:use-macro="here/teaser_view/macros/main">
          Kontaktdaten
        </div>
      </div>
</div>

Wie kann ich das eleganter lösen?

-- 
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult mit Mitglied bei http://www.7-it.de



_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
smime.p7s (application/pkcs7-signature, 4.6 KB) - not displayed
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.