Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

is possible use request.set in a zpt?

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


yourpadre at gmail

Jun 26, 2009, 7:23 PM

Post #1 of 5 (1041 views)
Permalink
is possible use request.set in a zpt?

Hi list

I used before with dtml something like this
<dtml-call "request.set('sumVar',0)">
<dtml-in ...>
<dtml-call "request.set('sumVar', sumVar + queryVar)">
</dtml-in>
The sum is <dtml-var sumVar>

This is possible to made with ZPT?
--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida


tseaver at palladion

Jun 26, 2009, 7:34 PM

Post #2 of 5 (955 views)
Permalink
Re: is possible use request.set in a zpt? [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Miguel Beltran R. wrote:
> Hi list
>
> I used before with dtml something like this
> <dtml-call "request.set('sumVar',0)">
> <dtml-in ...>
> <dtml-call "request.set('sumVar', sumVar + queryVar)">
> </dtml-in>
> The sum is <dtml-var sumVar>
>
> This is possible to made with ZPT?

It is possible...

<div tal:define="ignored python:request.set('sumVar', 0)">

but not recommended. The kind of logic you are trying to wedge into the
template should be pushed out into a Python script, leaving the template
only with the job of rendering the results.


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver[at]palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKRYVA+gerLs4ltQ4RAoaPAKCs6/ILvD+1i5kA5UtVvqJwWpk+xwCg2u++
5aEKQ0j4qUQdx23uC5gsD94=
=zdwr
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist - Zope[at]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 )


yourpadre at gmail

Jun 27, 2009, 8:15 AM

Post #3 of 5 (953 views)
Permalink
Re: is possible use request.set in a zpt? [In reply to]

>
>
>
> It is possible...
>
> <div tal:define="ignored python:request.set('sumVar', 0)">
>
> but not recommended. The kind of logic you are trying to wedge into the
> template should be pushed out into a Python script, leaving the template
> only with the job of rendering the results.
>
>
> Tres.
> - --
>

I want show tabular data with money and the last show the sum
can you explain me how can made better this then? almost never use python
script :P

Thanks


lists at zopyx

Jun 27, 2009, 9:36 AM

Post #4 of 5 (947 views)
Permalink
Re: is possible use request.set in a zpt? [In reply to]

On 27.06.09 17:15, Miguel Beltran R. wrote:
>
>
>
> It is possible...
>
> <div tal:define="ignored python:request.set('sumVar', 0)">
>
> but not recommended. The kind of logic you are trying to wedge
> into the
> template should be pushed out into a Python script, leaving the
> template
> only with the job of rendering the results.
>
>
> Tres.
> - --
>
>
> I want show tabular data with money and the last show the sum
> can you explain me how can made better this then? almost never use
> python script :P

Huh? Write a PythonScript (yes, you should know some basic Python)
returning the
data as dict or list or something similar...then render the result as needed
using ZPT. Should be documented in The Zope Book (docs.zope.org).

-aj
Attachments: lists.vcf (0.31 KB)


yourpadre at gmail

Aug 31, 2009, 3:19 PM

Post #5 of 5 (615 views)
Permalink
Re: is possible use request.set in a zpt? [In reply to]

2009/8/25 José Henrique <jhreis[at]gmail.com>

> 2009/6/26 Miguel Beltran R. <yourpadre[at]gmail.com>:
> > Hi list
> >
> > I used before with dtml something like this
> > <dtml-call "request.set('sumVar',0)">
> > <dtml-in ...>
> > <dtml-call "request.set('sumVar', sumVar + queryVar)">
> > </dtml-in>
> > The sum is <dtml-var sumVar>
> >
> > This is possible to made with ZPT?
> > --
> > ________________________________________
>
> What about this way:
>
>
> <dtml-in expr="(1,2,3)" prefix="rows">
> <dtml-var expr="rows_item"><br>
> <dtml-if expr="rows_end">
> Total: <dtml-var expr="rows_total_item">
> </dtml-if>
> </dtml-in>
>
> José Henrique
>

How say Andreas and Tres, I made a script

[suma_py]
parameters:
rec, campo
code:
suma=0
for r in rec:
suma+=r[campo]
return suma


[index_html]
<div tal:define="items aquery()">
<div tal:repeat="item items">
...
</div>
<div>
el importe es <span tal:content="suma_py(items, 'importe')">
la cantidad es <span tal:content="suma_py(items, 'cantidad')">
</div>
</div>
--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.