[Zope] Re: returning a macro from a pythonscript

2007-03-02 Thread Tonico Strasser

Gaute Amundsen schrieb:

foo = restrictedTraverse('/foo/bar/index.html/macros/mymacro')


You can use this macro in a template.



Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: metal:fill-slot and tal:condition

2007-02-22 Thread Tonico Strasser

Dragos Chirila schrieb:

Hi everybody,

I am stuck with the following problem. I would appreciate it very much
if you could help me with it.


[snip]

If I understand correctly you want to fill a slot if a condition is true 
else leave the default.


A typical "slot-modell" looks something like this:

Template I:


  
default
  


Template II:


  
custom
  


A different approach, a "use-macro-modell":

Template I:


  


Python Script getmacros:

macros = {}
# default_macros, custom_macros are page templates.
macros.update(container.default_macros.macros)
if blah:
macros.update(container.custom_macros.macros)
return macros

This is oversimplified, but I hope it helps you to find a solution.

Regards,
Tonico





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: nested metal macros

2006-08-22 Thread Tonico Strasser

Antonio Beamud Montero schrieb:

Ok... I want to define a template (like a skeleton), other template
(like the body of the skeleton) and lot of templates in sections of the
body of the skeleton and reuse the skeleton and the body across all my
web... How I can do that? It's posible or only one level of macro
definitions is posible? Where I can find examples or resources about
that...?


Maybe the new MacroExtension feature is what you need:
http://www.zope.org/Wikis/DevSite/Projects/ZPT/MacroExtension

I'm not sure if it's possible with Zope 2.x Page Templates though.

HTH,
Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: FastCGI server crashing

2006-08-08 Thread Tonico Strasser

Jens Vagelpohl schrieb:

... FastCGI is no longer a supported configuration.


Just out of curiosity, why isn't it supported anymore?

Thx,
Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: page templates and "python:"

2006-07-03 Thread Tonico Strasser

Andreas Jung schrieb:



--On 3. Juli 2006 15:50:41 +0200 Tonico Strasser 
<[EMAIL PROTECTED]> wrote:



Claudio Battaglino schrieb:

Hi,
what does exactly happen when I use "python:" into a zpt?
Is it a problem if I have many "python:" in my page templates?


Path expressions are by far better human readable IMHO. I try very hard
to avoid Python expressions if possible.


(Un)fortunately we live a in world where methods may have parameters. 
Path expressions work only for parameter-less methods.


This can be avoided if you "prepare" a namespace and pass it to the 
template, this way the template doesn't need to call methods.


I've written a simple page class for doing this, but it's also possible 
TTW from a Python script:


  names = {'foo': 'bar'}
  template = context.a_page_template
  return template.pt_render(extra_context=names)

Of course you can still use Python expressions if needed.

Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: page templates and "python:"

2006-07-03 Thread Tonico Strasser

Small correction ...




Should be:





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: page templates and "python:"

2006-07-03 Thread Tonico Strasser

Claudio Battaglino schrieb:

Hi,
what does exactly happen when I use "python:" into a zpt?
Is it a problem if I have many "python:" in my page templates?


Path expressions are by far better human readable IMHO. I try very hard 
to avoid Python expressions if possible.


To give you an example:

I prefer

. But also because in the first example the template doesn't need to 
know about implementation details and thus it is better reusable e.g. as 
macro.


Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: CSS Best practises

2006-03-24 Thread Tonico Strasser

Tino Wildenhain schrieb:

Tonico Strasser schrieb:

Tino Wildenhain schrieb:


... flexibility w/o slow and error prone full dynamic
stylesheets.



Plain text/css files are slow too if you don't cache 'em.


But you can, thats the whole point.


You can cache dynamic stylesheets too, why not? :)

If I just want dynamic URLs in my stylesheet this makes perfect sense.

Of course there are use cases where you don't want to cache a 
stylesheet, but then you don't want static files.


E.g. for a Web site that needed a random background I made a small 
dynamic stylsheet which does only this.


Another use case might be a small stylesheet which imports other 
(cacheable) stylesheets based on some logic.


Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: CSS Best practises

2006-03-24 Thread Tonico Strasser

Tino Wildenhain schrieb:

... flexibility w/o slow and error prone full dynamic
stylesheets.


Plain text/css files are slow too if you don't cache 'em.

Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: best practice, CSS Stylesheets

2006-03-23 Thread Tonico Strasser

Tino Wildenhain schrieb:

David Pratt schrieb:

Anyone have any idea whether dynamic css via dtml will remain possible
as CMF gets more Z3'ish? Or will only possibility be overrides in css
itself.


What do you expect to change with Z3? Otoh, not using runtime-generated
CSS is usually a better approach anyway.


Just out of interest, why do you think this is *usually* better? This 
does strongly depend on your use case, no?


You could say something like "it is usually better to serve static HTML 
pages" as well.


Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: best practice, CSS Stylesheets

2006-03-21 Thread Tonico Strasser

Tino Wildenhain schrieb:

Peter Bengtsson schrieb:



John Huttley wrote:


Hi,
What is the best way of handling CSS?
I've looked at ZStylesheets, but it is buggy and uses depreciated 
functions that will not be available in 2.10.



I recommend a DTML Document as an upgrade to File objects.
If you use DTML you can
a) easily set some custom cache headers in the css


Or use a cache manager :-)


b) refer to images by a dynamic URL to the imagefolder. *

* example:
#body { background:#fff url(/bg.png); }


Which runs against (a) because if you aggressive cache
(which is a good idea) you shouldn't have dynamic elements
in it.

I believe file objects are good enough and you could
probably split the CSS across some files to get the
dynamics w/o loosing performance.


I also use DTML for dynamic stylesheets plus a HTTPCacheManager and a 
set_header script to set the text/css media type (and /* vim: set 
syn=css: */).


Only because I'm lazy to change the paths (mainly for @import) in the 
stylesheets.


Tonico

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: [ZPT] Recursive structures

2005-07-01 Thread Tonico Strasser

Nikko Wolf schrieb:

Ian Bicking wrote:

I'm surprised this has never come up for me before, but now I want to 
render a recursive data structure and I'm at a loss how I might do 
that in ZPT.  Or, what the best workaround would be.  E.g.:


['a', 'b', ['c', ['d', 'e']]]

Becomes:


 a
 b
 
  c
  
   d
   e
  
 



The code above is not valid HTML[1]. This is one way how to do it:


  


  

  


I guess the template could call itself repeatedly.  Which means the 
list can't be embedded in any other markup.


To embed it in another template simply call it:



(Or define a macro and use that).

Even better if the logic is in a script that renders the template, I think.

Tonico

[1]  can not have  as parent
http://zvon.org/xxl/xhtmlReference/Output/Strict/el_ul.html

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: How to find out the full URL

2005-05-12 Thread Tonico Strasser
Hong Yuan schrieb:
I have a page template, say 'products.pt', which takes 
traverse_subpath[0] as one of the variables, so e.g. the URL:
 http://myserver/products/100
will actually call products.pt, which get 100 from the URL and displays 
it in the template.

Now my question is how can I get the full URL from within the tempalte 
'products.pt'? If I use 'request/URL' it will show 
'http://myserver/products' only, with the subpath somehow dropped. How 
can I get the '/100' part back?

Ideally, I'd like to get back the whole URL as entered in the browser as 
a string. From the REQUEST I have to put together URL and QUERY_STRING, 
and the section (#xxx) part of the url can not be found in REQUEST.
Hi, something like this?:

The script is here:

HTH
Tonico
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )