Re: [Zope] Dictionary in ZPT

2006-09-28 Thread Chris Withers

Pascal Peregrina wrote:

Hi,

I am not sure about your use case, but this should work:

...
tal:define=global count python: 0; global data python: {}
...
tal:define=null python: data.update({'jname':jname});
...


...and anyone writing code like that should be taken out back and loudly 
shot...


Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-28 Thread Pascal Peregrina
100% agree... Just answered the specific question ;)


 De : Chris Withers [EMAIL PROTECTED]
 Date : Thu, 28 Sep 2006 09:07:33 +0100
 À : Pascal Peregrina [EMAIL PROTECTED]
 Cc : Alan [EMAIL PROTECTED], zope@zope.org
 Objet : Re: [Zope] Dictionary in ZPT
 
 Pascal Peregrina wrote:
 Hi,
 
 I am not sure about your use case, but this should work:
 
 ...
 tal:define=global count python: 0; global data python: {}
 ...
 tal:define=null python: data.update({'jname':jname});
 ...
 
 ...and anyone writing code like that should be taken out back and loudly
 shot...
 
 Chris
 
 -- 
 Simplistix - Content Management, Zope  Python Consulting
 - http://www.simplistix.co.uk



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**
___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-27 Thread Pascal Peregrina
Hi,

I am not sure about your use case, but this should work:

...
tal:define=global count python: 0; global data python: {}
...
tal:define=null python: data.update({'jname':jname});
...

Pascal

 De : Alan [EMAIL PROTECTED]
 Date : Tue, 12 Sep 2006 14:16:23 +0100
 À : zope@zope.org
 Objet : [Zope] Dictionary in ZPT
 
 Dears,
 
 I am looking for help.
 
 I want to pass, when submitting a FORM from a page template, dictionary.
 
 I started with that:
 tal:define=global count python: 0; global data python: {}
 ...
 and I would like to do something like:
   tal:define=global data['jname'] python: jname
 or
   tal:define=global null python: data['jname']=jname
 
 But I get only error.
 
 Is there a way of creating and increasing a dict inside Zope template page?
 
 Many thanks in advance.
 
 Cheers,
 Alan
 
 -- 
 Alan Wilter S. da Silva, D.Sc. - Research Associate
 Department of Biochemistry, University of Cambridge.
 80 Tennis Court Road, Cambridge CB2 1GA, UK.
 http://www.bio.cam.ac.uk/~awd28
 ___
 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 )



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**
___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-13 Thread Chris Withers

Martijn Pieters wrote:

On 9/12/06, Andreas Jung [EMAIL PROTECTED] wrote:

tal:define=dummy python: somedict.update({key:value})


See, I never manipulate dictionaries in TAL and forgot you had to do
it that way. I gave the wrong answer in my reply.


That's because manipulating dictionaries in a ZPT is just plain evil :-(

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
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] Dictionary in ZPT

2006-09-12 Thread Alan

Dears,

I am looking for help.

I want to pass, when submitting a FORM from a page template, dictionary.

I started with that:
tal:define=global count python: 0; global data python: {}
...
and I would like to do something like:
 tal:define=global data['jname'] python: jname
or
 tal:define=global null python: data['jname']=jname

But I get only error.

Is there a way of creating and increasing a dict inside Zope template page?

Many thanks in advance.

Cheers,
Alan

--
Alan Wilter S. da Silva, D.Sc. - Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.

http://www.bio.cam.ac.uk/~awd28

___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-12 Thread Andreas Jung



--On 12. September 2006 14:16:23 +0100 Alan [EMAIL PROTECTED] wrote:


Dears,

I am looking for help.

I want to pass, when submitting a FORM from a page template, dictionary.

I started with that:
tal:define=global count python: 0; global data python: {}
...
and I would like to do something like:
  tal:define=global data['jname'] python: jname
or
  tal:define=global null python: data['jname']=jname



You can perform assignment that way in ZPT. First it is bad style.
You really want to prepare your data inside a PythonScript, call
the script from a ZPT and re-use the data as returned from the script.
If you don't want follow that road, try this:

tal:define=dummy python: somedict.update({key:value})

-aj


pgpG4Zll9kMQy.pgp
Description: PGP signature
___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-12 Thread Martijn Pieters

On 9/12/06, Alan [EMAIL PROTECTED] wrote:

I started with that:
tal:define=global count python: 0; global data python: {}
...
and I would like to do something like:
  tal:define=global data['jname'] python: jname
or
  tal:define=global null python: data['jname']=jname


Just tal:define=null python:data['jname'] = jname should do. No need
to make the dummy var global anyway.


But I get only error.


Traceback please. What is the error?


Is there a way of creating and increasing a dict inside Zope template page?


Why do you want to? Use a python script instead, or better still, use
a Zope3-style view.

--
Martijn Pieters
___
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 )


Re: [Zope] Dictionary in ZPT

2006-09-12 Thread Martijn Pieters

On 9/12/06, Andreas Jung [EMAIL PROTECTED] wrote:

tal:define=dummy python: somedict.update({key:value})


See, I never manipulate dictionaries in TAL and forgot you had to do
it that way. I gave the wrong answer in my reply.

--
Martijn Pieters
___
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 )