[ZPT] Structural Logic: Really, It Is...

beno zope@thewebsons.com
Tue, 08 Oct 2002 17:31:09 -0400


At 07:17 PM 10/8/2002 +0200, you wrote:

>beno writes:
>  > Hi;
>  > Although several have tried to help me with this problem, it still 
> remains
>  > unsolved, so I'll restate it. I have the following code:
>  >
>  > <font style="font" tal:attributes="style
>  > python:here.sizeCalc(44,here.size(None,  here))" >
>  >
>  > This is Page Template <em tal:content="template/id">template 
> id</em>.</font>
>  >
>  > ]]or, alternately... [[
>  >
>  > <el tal:define="fsize python:here.sizeCalc(44, here.size(None, here))"
>  >      tal:attributes="style string:font-size: ${fsize};" >
>  >
>  > This is Page Template <em tal:content="template/id">template id</em>.</el>
>  >
>  > However, neither of these render what I'm trying to accomplish, namely,
>  > changing the font size by calling a python script (sizeCalc) and 
> passing a
>  > variable (size) as a parameter. What am I missing?
>
>Ah, size is a _variable_, not a function/script/whatever !
>Why don't You tell ;-)
>In the original DTML version this read:
>
>  <dtml-var "sizeCalc(204,size(_.None,_))">
>
>this looks like "size" is a function ...
>
>Maybe Your problem is that You do not have a merged undernamespace in
>ZPT as in DTML, but have to be explicit where your thingies live.
>If its a variable defined with tal:define, sometimes a "global" helps.
>Well, this time You did not mail an error message, thus its impossible
>to guess whats the problem.

Oops. No error, so I viewed source--something I'd done all along but 
*forgot* this time--and figured out how to answer my own question. Here's 
the correct line of code (although I've disposed of the CSS *style* elt.):

<font size="font" tal:attributes="size 
python:here.sizeCalc(44,here.size(None,  here))" >

To answer your question, my variable *size* is simply a number in a DTML 
Method in a folder that is placed into the address after a ping determines 
the screen resolution of the browser. For example, if you're surfing at 
1024 by 786, then you're redirected to:
some_web_site/1024/eng/index.zpt
Both *eng* and *1024* are folders on the same level. Within 1024 (as within 
all browser folders--800, 640, etc.) is the DTML Method *size*. This is 
then used to render text and images such that they scale to the individual 
browser. The *reason* I do this is because I'm a marketer and I want to 
control the user's experience with my Web sites. It's my goal to make the 
Web site look the same in everyone's browser. When I surf at 1024*786 and 
hit a site built for 800*600 (very common) the text is usually so small I 
have a hard time reading it. Bad, bad, marketing. But then again, how many 
IT professionals are marketing professionals?

Thanks for your help,
beno