Re: [Zope-dev] Setting vars in expression eval() namespace

2001-02-22 Thread Steve Alexander

Julio Maia wrote:

  Hi,
 
  I'm trying to create a tag to evaluate the expression passed to it,
  adding in the expression eval namespace a variable that contains
  the result of dtml processing of the tag's block. For instance, the
   following construct:
 
  dtml-bvar "foo(a=1)" var="block"
some text dtml-var "1+2"
  /dtml-bvar
 
  would invoke the expression "foo(a=1)" with a variable named 'block'
   set to 'some text 3' in the expression's namespace (btw, is it
  possible to achieve this using regular dtml?).

This may be too simple example, but how about:

dtml-var "foo(a=1, block=('some text %s' % (1+2)))"

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Setting vars in expression eval() namespace

2001-02-22 Thread Julio Maia

On Wed, Feb 21, 2001 at 10:53:54PM +, Steve Alexander wrote:
 Julio Maia wrote:
 
  
  This is not going to be handy once the block is composed by a large dtml
  block. I wonder if dtml-var shouldn't support the syntax I've described
  above.
 
 I suggest instead using a PythonScript, and using the DTML class that you
 can import from the Products.PythonScripts.standard module.
 
 You can use this to render DTML on the fly, as you wish.

I guess it would be better to allow constructs as:

dtml-var "table('main','col')"
   dtml-var "font('standard')"Some text/dtml-var 
/dtml-var

Where 'table' and 'font' are PythonScripts that return the implicit blocks passed to 
them (these blocks may have a default variable name in the expression's namespaces) 
enclosed by the correspondent html blocks, with the format ('main, 'standard') mapped 
to html attributes/values using some dictionaries. This could help to separate logic 
and presentation in dtml code with a minor syntax addition.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Setting vars in expression eval() namespace

2001-02-22 Thread Steve Alexander

Julio Maia wrote:

 
 This is not going to be handy once the block is composed by a large dtml
 block. I wonder if dtml-var shouldn't support the syntax I've described
 above.

I suggest instead using a PythonScript, and using the DTML class that you
can import from the Products.PythonScripts.standard module.

You can use this to render DTML on the fly, as you wish.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net
 
 



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Setting vars in expression eval() namespace

2001-02-22 Thread Julio Maia

On Wed, Feb 21, 2001 at 10:24:57PM +, Steve Alexander wrote:
 Julio Maia wrote:
 
   Hi,
  
   I'm trying to create a tag to evaluate the expression passed to it,
   adding in the expression eval namespace a variable that contains
   the result of dtml processing of the tag's block. For instance, the
following construct:
  
   dtml-bvar "foo(a=1)" var="block"
 some text dtml-var "1+2"
   /dtml-bvar
  
   would invoke the expression "foo(a=1)" with a variable named 'block'
set to 'some text 3' in the expression's namespace (btw, is it
   possible to achieve this using regular dtml?).
 
 This may be too simple example, but how about:
 
 dtml-var "foo(a=1, block=('some text %s' % (1+2)))"

This is not going to be handy once the block is composed by a large dtml block. I 
wonder if dtml-var shouldn't support the syntax I've described above.

 
 --
 Steve Alexander
 Software Engineer
 Cat-Box limited
 http://www.cat-box.net
 
 

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Setting vars in expression eval() namespace

2001-02-22 Thread Dieter Maurer

Julio Maia writes:
  I'm trying to create a tag to evaluate the expression passed to it, adding in the 
 expression eval namespace a variable that contains the result of dtml processing of 
 the tag's block. For instance, the following construct:
  
  dtml-bvar "foo(a=1)" var="block"
 some text dtml-var "1+2"
  /dtml-bvar
  
  would invoke the expression "foo(a=1)" with a variable named 'block' set to 'some 
 text 3' in the expression's namespace (btw, is it possible to achieve this using 
 regular dtml?).
What a construction! I do not like it.

  However, I couldn't find a way to set a variable in the namespace used in the 
 evaluation of the expression. I've tried to insert an entry in the mappings passed to 
 the expression eval() method as follows:
Push a new mapping onto the namespace (with its "push" method).
Do not forget, to pop it after your tag.


Dieter

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )