[Zope] page templates and python:

2006-07-03 Thread Claudio Battaglino

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?
What are the differences in performances of these two definitions?

metal:block tal:define=my_value my_object/getValue.../metal:block

metal:block tal:define=my_value 
python:my_object.getValue().../metal:block


thank you very much

claudio :-)
___
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] page templates and python:

2006-07-03 Thread Andreas Jung



--On 3. Juli 2006 15:05:36 +0200 Claudio Battaglino 
[EMAIL PROTECTED] wrote:



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?
What are the differences in performances of these two definitions?


Talking of performance...you might write a benchmark to figure it out...
no idea


metal:block tal:define=my_value my_object/getValue.../metal:block

metal:block tal:define=my_value
python:my_object.getValue().../metal:block



The main difference between both variants is that in path expressions 
getValue can be either an attribute or a method...so at least path 
expressions may have some overhead...you have to measure it.


-aj

pgp2Bb8wDjS0s.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] page templates and python:

2006-07-03 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 3 Jul 2006, at 15:09, Andreas Jung wrote:



metal:block tal:define=my_value my_object/getValue.../ 
metal:block


metal:block tal:define=my_value
python:my_object.getValue().../metal:block



The main difference between both variants is that in path  
expressions getValue can be either an attribute or a method...so at  
least path expressions may have some overhead...you have to measure  
it.


As far as I know path expressions have better performance. I don't  
have the in-depth expression engine knowledge to explain why, but  
that's been what everyone has said to me before.


jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEqRmaRAx5nvEhZLIRAhsIAJsHRlq94iq7c0wbeGN92JhlikUFwgCfaClc
b16sWokKTRVrWo4BtvRGVhg=
=tt4I
-END 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] page templates and python:

2006-07-03 Thread Claudio Battaglino

Jens Vagelpohl ha scritto:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 3 Jul 2006, at 15:09, Andreas Jung wrote:



metal:block tal:define=my_value my_object/getValue.../ 
metal:block


metal:block tal:define=my_value
python:my_object.getValue().../metal:block



The main difference between both variants is that in path expressions 
getValue can be either an attribute or a method...so at least path 
expressions may have some overhead...you have to measure it.



As far as I know path expressions have better performance. I don't 
have the in-depth expression engine knowledge to explain why, but 
that's been what everyone has said to me before.


jens


Could it be that, using a Python expression, I have an overhead because 
Zope loads a Python interpreter each time it finds a python:?

If this is true then it is better to use path expression, if possible.

claudio :-)





___
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] page templates and python:

2006-07-03 Thread Andreas Jung



--On 3. Juli 2006 15:38:58 +0200 Claudio Battaglino 
[EMAIL PROTECTED] wrote:



Jens Vagelpohl ha scritto:



Could it be that, using a Python expression, I have an overhead because
Zope loads a Python interpreter each time it finds a python:?
If this is true then it is better to use path expression, if possible.



nahPython expression are executed in a sandbox (RestrictedPython) which 
will introduce additional overhead..but let numbers speak...write a loop in 
TAL and compare the performance of path expressions vs. python 
expressions... don't guess, but measure...


-aj

pgpZL6GLQNSgL.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 )


[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

option tal:attributes=selected item/selected ...

over

option tal:attributes=python: test(foo == bar, 'selected', None) ...

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


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

2006-07-03 Thread Andreas Jung



--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.


-aj


pgpxdaU9NjPMD.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 )


[Zope] Re: page templates and python:

2006-07-03 Thread Tonico Strasser

Small correction ...


option tal:attributes=python: test(foo == bar, 'selected', None) ...


Should be:

option tal:attributes=selected python: test(foo == bar, 'selected', 
None) ...




___
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] page templates and python:

2006-07-03 Thread Chris McDonough
Actually, I think python: expressions perform slightly better than  
their path: counterparts because their evaluation step needs to do  
less work (no guessing about getitem vs. getattr).  Geoff Davis  
taught me that.  But in the end it's all dwarfed by the penalty  
imposed by security, so it really doesn't much matter.


On Jul 3, 2006, at 9:20 AM, Jens Vagelpohl wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 3 Jul 2006, at 15:09, Andreas Jung wrote:



metal:block tal:define=my_value my_object/getValue.../ 
metal:block


metal:block tal:define=my_value
python:my_object.getValue().../metal:block



The main difference between both variants is that in path  
expressions getValue can be either an attribute or a method...so  
at least path expressions may have some overhead...you have to  
measure it.


As far as I know path expressions have better performance. I don't  
have the in-depth expression engine knowledge to explain why, but  
that's been what everyone has said to me before.


jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEqRmaRAx5nvEhZLIRAhsIAJsHRlq94iq7c0wbeGN92JhlikUFwgCfaClc
b16sWokKTRVrWo4BtvRGVhg=
=tt4I
-END 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 )



___
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] wher i can find network device content types to develop network manage system?

2006-07-03 Thread Jean Jordaan
Hi LYNN

 develope a network manage sytem based on zope/plone on web.

Maybe you can find something useful here:
  http://zenoss.org/


Zenoss is a powerful, integrated, easy-to-use IT infrastructure monitoring
software product.
[...]
Zenoss is a written in Python using Zope, MySQL, RRDtool, PySNMP, Net-SNMP,
libsmi, sendpage, Twisted and several other open source components.


-- 
jean
___
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] page templates and python:

2006-07-03 Thread Lennart Regebro

On 7/3/06, Chris McDonough [EMAIL PROTECTED] wrote:

Actually, I think python: expressions perform slightly better than
their path: counterparts because their evaluation step needs to do
less work (no guessing about getitem vs. getattr).  Geoff Davis
taught me that.  But in the end it's all dwarfed by the penalty
imposed by security, so it really doesn't much matter.


Right. So the best and quickest is to prepare all the data in pure
disk-based python.
It's easy to do if you use the view methodology you get with Five, but
there are other ways to do it if you don't want to use views.
___
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] page templates and python:

2006-07-03 Thread Claudio Battaglino

Andreas Jung ha scritto:




--On 3. Juli 2006 15:38:58 +0200 Claudio Battaglino 
[EMAIL PROTECTED] wrote:



Jens Vagelpohl ha scritto:




Could it be that, using a Python expression, I have an overhead because
Zope loads a Python interpreter each time it finds a python:?
If this is true then it is better to use path expression, if possible.



nahPython expression are executed in a sandbox (RestrictedPython) 
which will introduce additional overhead..but let numbers 
speak...write a loop in TAL and compare the performance of path 
expressions vs. python expressions... don't guess, but measure...


-aj


It seems that the Python Expression works a bit better:

To the test this, I used these two Page Templates and PTProfiler:

PATH EXPRESSION 
   div tal:define=test_user here/portal_membership/getAuthenticatedMember tal:repeat=counter python:range(5000)

 span tal:content=test_user/getId /
   /div

PYTHON EXPRESSION
   div tal:define=test_user here/portal_membership/getAuthenticatedMember 
tal:repeat=counter python:range(5000)
 span tal:content=python: test_user.getId() /
   /div

PATH EXPRESSION 
Expression - Total time - Number of calls - Time per call

path: test_user/getId   0.7250000.00014
path: test_user/getId   0.6350000.00013
path: test_user/getId   0.7250000.00014

path: test_user/getId   4.0 5   8e-05
path: test_user/getId   4.095   8e-05
path: test_user/getId   4.125   8e-05

PYTHON EXPRESSION
Expression - Total time - Number of calls - Time per call
python: test_user.getId()   0.6 50000.00012
python: test_user.getId()   0.5150000.0001
python: test_user.getId()   0.4850000.0001
python: test_user.getId()   3.195   6e-05
python: test_user.getId()   3.425   7e-05
python: test_user.getId()   2.965   6e-05

Is it a  significant test?

claudio :-)

___
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 Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lennart Regebro wrote:
 On 7/3/06, Chris McDonough
 [EMAIL PROTECTED] wrote:
 Actually, I think python: expressions perform slightly better than
 their path: counterparts because their evaluation step needs to do
 less work (no guessing about getitem vs. getattr).  Geoff Davis
 taught me that.  But in the end it's all dwarfed by the penalty
 imposed by security, so it really doesn't much matter.
 
 Right. So the best and quickest is to prepare all the data in pure
 disk-based python.
 It's easy to do if you use the view methodology you get with Five, but
 there are other ways to do it if you don't want to use views.

My 'pushpage' package is an attempt to make this the standard pattern
(pushpage templates don't have *any* top-level names available to them
(i.e., 'context', 'container', 'request', etc.) except those passed to
their '__call__' as keyword arguments (which traditional ZPT exposes
under 'options'):

  http://agendaless.com/Members/tseaver/software/pushpage

The templates can be used from within methods of view classes, and can
also be published as pages via ZCML with the help of a user-defined
callable which computes the keyword arguments.  E.g.:

  pushpage:view
for=.interfaces.ISomeContentInterface
name=somepage.html
permission=zope.Public
template=templates/sometemplate.pt
mapping=.somemodule,somefunction
layer=mylayer
/

In this example, 'somemodule.somefunction' returns the mapping which
'sometemplate' will use as its top-level namespace.  The callable is
passed 'context' and 'request' as arguments.


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEqTxk+gerLs4ltQ4RArSWAJ90L7NT76aPuaIk9a7cQj222qYM6QCfRPrZ
gN4Q7fIm63hA4HUoViIwdBk=
=2aTX
-END 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] page templates and python:

2006-07-03 Thread Lennart Regebro

On 7/3/06, Claudio Battaglino [EMAIL PROTECTED] wrote:

Is it a  significant test?


Yes, for the use case of in-memory objects and methods.
You might want to do the same with a traversal path
nocall:context/folder1/folder2/folder3, or something, and then
python:context.folder1.folder2.folder3

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
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] [ANN] TextIndexNG 3.1.10 released

2006-07-03 Thread MIlos Prudek
On Saturday 03 of June 2006 15:28, Andreas Jung wrote:
 I am pleased to announce the release of TextIndexNG V 3.1.10

Hi,

I have just tried TextIndexNG V 3.1.9 in Zope 2.9.3 and it shows in 
Control_Panels/Products as installed... I did compile the modules as required 
by README... but an instance of TextIndexNG cannot be added, because it is 
not among addable types. Is this normal? Does TextIndexNG3 have a web 
interface?
 
-- 
Milos Prudek
___
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] [ANN] TextIndexNG 3.1.10 released

2006-07-03 Thread Andreas Jung



--On 3. Juli 2006 21:16:53 +0200 MIlos Prudek [EMAIL PROTECTED] wrote:


On Saturday 03 of June 2006 15:28, Andreas Jung wrote:

I am pleased to announce the release of TextIndexNG V 3.1.10


Hi,

I have just tried TextIndexNG V 3.1.9 in Zope 2.9.3 and it shows in
Control_Panels/Products as installed... I did compile the modules as
required  by README... but an instance of TextIndexNG cannot be added,
because it is  not among addable types. Is this normal? Does TextIndexNG3
have a web  interface?


Huh? Since it is a index it must be added to a ZCatalog instance as any 
other index.


-aj

pgpGz0vcUVMaV.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] Rollback and delete weird behavior

2006-07-03 Thread dieter
Luiz Fernando B. Ribeiro wrote at 2006-7-1 14:24 -0300:
 ...
The problem is that the raise is not rolling back the delete, looking in 
mysql log the following sequence was found:

Be warned that mysql needs special precaution to be
transaction aware.

Your mysql connection may have been made transaction unaware
(to allow the use of non-transaction capable tables).



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