[Zope3-Users] test() in TALES in Zope3
Hi, in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? I know how to write such a method but how to make it available in the namespace of TALES-python:-expressions? I would like to write expressions like this: div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / Is this possible? Regards, Frank (*) found it here: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AdvZPT.stx (look for 'test(' ) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
--On 1. Februar 2006 09:04:36 +0100 Frank Burkhardt [EMAIL PROTECTED] wrote: Hi, in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? I know how to write such a method but how to make it available in the namespace of TALES-python:-expressions? I would like to write expressions like this: div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / You can write this in Python as condition and true_expression or false_expression -aj pgpV4jynQWzQQ.pgp Description: PGP signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
On Wed, Feb 01, 2006 at 09:04:36AM +0100, Frank Burkhardt wrote: [snip] div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / Is this possible? Impressing simple solution :-) . Thank you Andreas and Igor. Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Group membership based on authenticator
On Wednesday 01 February 2006 01:46, Marko Mikulicic wrote: subscriber for=zope.app.authentication.interfaces.IPrincipalCreated handler=.mytest.principalCreated / and then if the prefix of the event.principal.id is what I like then add some group to it, but I don't like the solution This is the right approach, I would just make the comparison a little bit smarter, looking up the prefix from the principal in the authentication utility. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Looking for PathIndex
On Feb 1, 2006, at 3:12 AM, Thierry FLORAC wrote: Hi ! I'm actually trying to create a Zope3 application, where I may be able to make queries : - looking for content in the whole site - looking for content in a given sub-site or list of sub-sites, eventually including all it's sub-folders. With Zope2, I was commonly using a PathIndex (mixed with other Text of Field indexes), but I can't find any reference to this index type in Zope3... Is it deprecated ? What is the best way to handle such queries with Zope3 ? Thanks for any help, Thierry P.S.: are the DateIndex and DateRangeIndex also deprecated ? They were very useful for me in Zope2... For code similar in effect to the Zope 2 DateIndex and DateRangeIndex, look at http://svn.zope.org/zc.catalog/trunk/src/zc/catalog/index.py?view=auto The bottom of the file has a DateTimeValueIndex and a DateTimeSetIndex. There's some discussion on what's going on here. The DateTimeValueIndex and DateTimeSetIndex are normalized versions of the value index and set index in the package. The value index, set index, and normalizing features all have their own .txt document. http://svn.zope.org/zc.catalog/trunk/src/zc/catalog/valueindex.txt? view=auto http://svn.zope.org/zc.catalog/trunk/src/zc/catalog/setindex.txt? view=auto http://svn.zope.org/zc.catalog/trunk/src/zc/catalog/ normalizedindex.txt?view=auto For all of the indexes' features, it needs to be used in an extent catalog, also in the zc.catalog package. For a path index, you could just have a set index (also in http://svn.zope.org/zc.catalog/trunk/src/zc/catalog/index.py?view=auto ) that was configured via an adapter to index the containing paths of any given object. For instance, if an object were at /foo/bar/baz/ bing, your adapter should return ['/foo', '/foo/bar', '/foo/bar/baz', and '/foo/bar/baz/bing'] Then searches for Give me everything in '/foo/bar' will return this object (as well as any others that are in the path). This approach would probably also work with the keyword index in standard Zope, but I haven't looked at that in a while. Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
On Feb 1, 2006, at 3:17 AM, Frank Burkhardt wrote: On Wed, Feb 01, 2006 at 09:04:36AM +0100, Frank Burkhardt wrote: [snip] div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / Is this possible? Impressing simple solution :-) . FWIW the classic Zope 3 solution is to say Don't do that in the template! Do it in the view class!. I'll let others add vigor, if they wish. I just wanted you to know the purist answer in case you cared. ;-) Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
--On 1. Februar 2006 07:56:47 -0500 Gary Poster [EMAIL PROTECTED] wrote: On Feb 1, 2006, at 3:17 AM, Frank Burkhardt wrote: On Wed, Feb 01, 2006 at 09:04:36AM +0100, Frank Burkhardt wrote: [snip] div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / Is this possible? Impressing simple solution :-) . FWIW the classic Zope 3 solution is to say Don't do that in the template! Do it in the view class!. I'll let others add vigor, if they wish. I just wanted you to know the purist answer in case you cared. ;-) If you have only one python: statement within your template then a view class is pretty much overhead (and a waste of manpower to write it)... just my 2 cents, -aj pgpozO5biEJFD.pgp Description: PGP signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
On Feb 1, 2006, at 8:07 AM, Andreas Jung wrote: --On 1. Februar 2006 07:56:47 -0500 Gary Poster [EMAIL PROTECTED] wrote: FWIW the classic Zope 3 solution is to say Don't do that in the template! Do it in the view class!. I'll let others add vigor, if they wish. I just wanted you to know the purist answer in case you cared. ;-) If you have only one python: statement within your template then a view class is pretty much overhead (and a waste of manpower to write it)... I hear ya. I figured someone ought to wave the purist flag, at least half-heartedly, though. :-) Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
RE: [Zope3-Users] test() in TALES in Zope3
Hi Andreas [...] FWIW the classic Zope 3 solution is to say Don't do that in the template! Do it in the view class!. I'll let others add vigor, if they wish. I just wanted you to know the purist answer in case you cared. ;-) If you have only one python: statement within your template then a view class is pretty much overhead (and a waste of manpower to write it)... just my 2 cents, -aj Don't forget about the better overview in the project if you put application logic in view classes. (No more page template reading and macro searching for a code review) And there are also security related aspects. Doing to much in ZPT will force scripters to map methods to the traversal namespace and ends in accessing context attributes in ZPT like context/@@title Regards Roger Ineichen ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
Andreas Jung wrote: Frank Burkhardt [EMAIL PROTECTED] wrote: in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? You can write this in Python as condition and true_expression or false_expression In Python 2.5 you'll be able to write true_expression if condition else false_expression -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
RE: [Zope3-Users] test() in TALES in Zope3
--On 1. Februar 2006 14:25:42 +0100 Roger Ineichen [EMAIL PROTECTED] wrote: Don't forget about the better overview in the project if you put application logic in view classes. (No more page template reading and macro searching for a code review) I knew that you love those kind of discussions :-) I agree mostly but there are situations where less code and less configuration is more :-) Something like test() or python: condtion and expr1 or expr2 are more or less self-explaining...no need to hide such code just for the sake of hiding it. -aj pgpW1pEzhY31R.pgp Description: PGP signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Please Guido, pick me, pick me!
Guido van Rossum is looking for a web app framework. http://blog.delaguardia.com.mx/index.php?op=ViewArticlearticleId=34blogId=1 Zope is conspicuous by its absence from the discussion. Hardly a mention, and no advocacy at all. Is Zope just too heavyweight for the project he has in mind? Or what? -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Please Guido, pick me, pick me!
Wade Leftwich wrote: Guido van Rossum is looking for a web app framework. http://blog.delaguardia.com.mx/index.php?op=ViewArticlearticleId=34blogId=1 Zope is conspicuous by its absence from the discussion. Hardly a mention, and no advocacy at all. Is Zope just too heavyweight for the project he has in mind? Or what? Seems Guido answer your questions himself. Quote from http://www.artima.com/forums/flat.jsp?forum=106thread=146503: From this perspective, Zope and Twisted are off the scale: they support the mix-and-match approach, offering several alternative solutions for many of the important issues (templating, persistence, authentication, etc.). But they only work if you drink lavish quantities of their particular flavor of kool-aid, and that's not good enough for me. I don't want to depend on any particular flavor of interfaces, adaptation, serialization, discovery, etc. I'm looking for solutions that depend only on the Python standard library, and use accepted Python idioms and patterns. Any takers? -- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
On Wed, 01 Feb 2006 09:07:17 +0100, Andreas Jung [EMAIL PROTECTED] said: --On 1. Februar 2006 09:04:36 +0100 Frank Burkhardt [EMAIL PROTECTED] wrote: Hi, in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? I know how to write such a method but how to make it available in the namespace of TALES-python:-expressions? I would like to write expressions like this: div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / You can write this in Python as condition and true_expression or false_expression That doesn't work under some conditions: C and A or B where C is a boolean if C is false it evaluates to B if C is true it evaluates to A EXCEPT when bool(A) == false example: C and None or 7 ALWAYS evaluates to 7 However, the expression (B,A)[C] always works if C is a boolean I'm using that until Python 2.5 comes along. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] test() in TALES in Zope3
Michael Dudzik wrote: On Wed, 01 Feb 2006 09:07:17 +0100, Andreas Jung [..] in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? I know how to write such a method but how to make it available in the namespace of TALES-python:-expressions? I would like to write expressions like this: div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / You can write this in Python as condition and true_expression or false_expression That doesn't work under some conditions: C and A or B where C is a boolean if C is false it evaluates to B if C is true it evaluates to A EXCEPT when bool(A) == false example: C and None or 7 ALWAYS evaluates to 7 Just make it 'not C and 7 or None' :) Igor ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Please Guido, pick me, pick me!
On Wednesday 01 February 2006 12:51, ksmith99 (sent by Nabble.com) wrote: He'll be back. After he finishes the project, Google will tweak the requirements a few times, and GvR will need to refactor. After he throws out and/or completely restructures 90% of his code, he'll look for a different solution. I'll just add that Guido was one of the early shapers/designers of ZCML. Interfaces, components and zcml will start looking real nice. I experienced the boomerang effect when RoR came out. I'm happy to be back. :) Very good to hear! Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Fwd: Re: [Zope3-Users] test() in TALES in Zope3
On Wed, 01 Feb 2006 19:15:13 +0100, Igor Stroh [EMAIL PROTECTED] said: Michael Dudzik wrote: On Wed, 01 Feb 2006 09:07:17 +0100, Andreas Jung [..] in Zope2 there's a test() method that can be used in TAL (*). Is there something comparable in Zope3? I know how to write such a method but how to make it available in the namespace of TALES-python:-expressions? I would like to write expressions like this: div tal:attributes=class python: 'foo' + test(condition == True,' bar','') / You can write this in Python as condition and true_expression or false_expression That doesn't work under some conditions: C and A or B where C is a boolean if C is false it evaluates to B if C is true it evaluates to A EXCEPT when bool(A) == false example: C and None or 7 ALWAYS evaluates to 7 Just make it 'not C and 7 or None' :) Sure, but what about when you don't know the boolean value ahead of time, like: C and f(x) or g(x) On the other hand, (g(x), f(x))[C] works every time To be fair, both g(x) and f(x) are evaluated while f(x) if C else g(x) # python 2.5, only evaluates the appropriate function. Still, I mostly spoke up because if one starts to use an idiom like: python:C and 'somestring' or 'anotherstring' you have to realize that python:C and '' or 'anotherstring' will fail. An idiom that breaks so easily doesn't seem so useful. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Fwd: Re: test() in TALES in Zope3
Michael Dudzik wrote: Sure, but what about when you don't know the boolean value ahead of time, like: C and f(x) or g(x) On the other hand, (g(x), f(x))[C] works every time To be fair, both g(x) and f(x) are evaluated while f(x) if C else g(x) # python 2.5, only evaluates the appropriate function. Still, I mostly spoke up because if one starts to use an idiom like: python:C and 'somestring' or 'anotherstring' you have to realize that python:C and '' or 'anotherstring' will fail. An idiom that breaks so easily doesn't seem so useful. In 90% of cases you'll have a fixed value for the true case or the false case, and you'll know that one cannot evaluate to false, in which case you can choose to use: C and foo or bar or not C and bar or foo depending on whether foo or bar is potentially false. In the remaining cases, you can use (C and [foo] or [bar])[0] if it's important to have short-circuit semantics. Florent -- Florent Guillaume, Nuxeo (Paris, France) Director of RD +33 1 40 33 71 59 http://nuxeo.com [EMAIL PROTECTED] ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Fwd: Re: test() in TALES in Zope3
On Wed, 01 Feb 2006 20:26:24 +0100, Florent Guillaume [EMAIL PROTECTED] said: Michael Dudzik wrote: Sure, but what about when you don't know the boolean value ahead of time, like: C and f(x) or g(x) On the other hand, (g(x), f(x))[C] works every time To be fair, both g(x) and f(x) are evaluated while f(x) if C else g(x) # python 2.5, only evaluates the appropriate function. Still, I mostly spoke up because if one starts to use an idiom like: python:C and 'somestring' or 'anotherstring' you have to realize that python:C and '' or 'anotherstring' will fail. An idiom that breaks so easily doesn't seem so useful. In 90% of cases you'll have a fixed value for the true case or the false case, and you'll know that one cannot evaluate to false, in which case you can choose to use: C and foo or bar or not C and bar or foo depending on whether foo or bar is potentially false. In the remaining cases, you can use (C and [foo] or [bar])[0] if it's important to have short-circuit semantics. But why not just use (bar,foo)[C] in all cases, regardless of the value of bar or foo? Or (bar,foo)[bool(C)] in case C might not be a boolean already. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Fwd: Re: test() in TALES in Zope3
On Wed, 1 Feb 2006 14:57:58 -0500, Paul Winkler [EMAIL PROTECTED] said: Prior to python 2.5, there is AFAIK no other always-works short-circuiting one-line conditional expression but this: (bool(C) and [foo] or [bar])[0] Agreed that that works every time, but so does: (bar,foo)[bool(C)] Each to his own idioms, I suppose. Generally I only care about this in TALES expressions; in python I prefer to use the extra couple of lines to use if and else. Same here, but I would be +1 on a python:test method readily available in page templates ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users