[ZPT] [BUG] something wrong with METAL (as bundled with Zope 2.5.1)

Dieter Maurer dieter@handshake.de
Thu, 8 Aug 2002 20:07:30 +0200


--v3WjcwyKsM
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

The templates that define macros appear to be looked up hundreds/thousands
of times. As lookup is very expensive in Zope (due to acquisition),
this is a considerable performance stopper.


How did I detect this problem:

  I had given a new product a "__getattr__" method.

  I was horrified by the time required to render my page templates in the
  context of these product instances.

  Thus, I added a "print" in my "__getattr__" to learn what 
  happens.
  The result: my "__getattr__" is called for seconds with a
  single name: the one I use in a
  'metal:use-macro="here/ThisOne/macros/Macro"'.


I attach the template defining the macros and the template using
the macro.


I will investigate and keep you informed...


Dieter

--v3WjcwyKsM
Content-Type: text/plain
Content-Description: Rendered ZPT
Content-Disposition: inline;
	filename="test.pt"
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
  <head>
    <title>Test</title>
  </head>

  <body>
    <h1>Test</h1>
    <div metal:use-macro="here/Feedback/macros/Feedback" />



    <hr>
    <address><a href="mailto:dieter@handshake.de">Dieter Maurer</a></address>
<!-- Created: Thu Aug  8 19:31:20 CEST 2002 -->
<!-- hhmts start -->
Last modified: Thu Aug  8 19:34:10 CEST 2002
<!-- hhmts end -->
  </body>
</html>

--v3WjcwyKsM
Content-Type: text/plain
Content-Description: Macro defining ZPT
Content-Disposition: inline;
	filename="Feedback.pt"
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<tal:div tal:define="PageTitle string:Feedback macros; FeedbackSuccessMessage string:Alles okay; FeedbackErrors python:('Fehler1', 'Fehler2',)">
	<html> <!-- metal:use-macro="container/Standard/macros/Page"> -->
	<head>
	<title tal:content="PageTitle">Slot: PageTitle</title>
	</head>
	<body>
		<h1>Feedback Komponenten</h1>
		<p>This template provides general macros for user feedback, such as reporting success or failure.</p>
		<h2>Success</h2>
		<p>This macro is used to inform the user about a successful operation. It is displayed, when <code>FeedbackSuccessMessage</code> is defined and non empty. This variable is used as message content.</p>
		<div
			metal:define-macro="Success"
			dmetal:arguments="FeedbackSuccessMessage"
			dmetal:description="render *FeedbackSuccessMessage*, if defined"
			tal:condition="FeedbackSuccessMessage | nothing">
			<span class="FeedbackSuc"
				tal:content="FeedbackSuccessMessage">Successfull</span>
		</div>
		<h2>Errors</h2>
		<p>This macro is used to inform the user about a failed operation. It interpretes the <code>FeedbackErrors</code> variable which must be sequence of error messages.</p>
		<div
			metal:define-macro="Errors"
			dmetal:arguments="FeedbackErrors"
			dmetal:description="render *FeedbackErrors*, a sequence error messages, if defined"
			tal:condition="FeedbackErrors | nothing">
			<div tal:repeat="error FeedbackErrors">
			<span tal:content="error" class="FeedbackErr">Error</span><br/></div>
		</div>
		<h2>Feedback</h2>
		<p>This macro combines <code>Success</code> and <code>Errors</code></p>
		<div metal:define-macro="Feedback"
			dmetal:arguments="FeedbackSuccessMessage; FeedbackErrors"
			dmetal:description="provide feedback to the user about the latest operation">
			<div metal:use-macro="here/Feedback/macros/Success">Success report</div>
			<div metal:use-macro="here/Feedback/macros/Errors">Errors report</div>
		</div>
	</body></html></tal:div>

--v3WjcwyKsM--