Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-30 Thread Jeff Shell
Actually, I just found another place where Python expressions are
handy. I have a simple but kindof specialized form - one that is too
simple and too specific to really go through the Zope schema system
without a lot of gnashing of teeth. It may be easier to do with
zope.formlib, but it's still not something I want to find out. With
only two radio buttons and a checklist (in one variation) that can
appear or disappear based on the radio button settings (via
Javascript) or the current configuration. Figuring out how to go
through all the schema stuff and present it in the way I want to
present it is just way too much work for this problem domain. So here
I am with:



I suppose I could go through and apply things to the view and set true
or false attributes like 'currentSettingIsEditors'
'currentSettingIsEverybody', but that seems a little ridiculous for
this situation.

This is a rare case as well, usually the zope.app.form or zope.formlib
material provides more than enough. But those are both overkill for
the situation I have here, especially when some simple Javascript
needs to be applied.

For the record - the formlib stuff doesn't really work here because
there's no real Schema of any kind to work with; it's a multiple
choice display with a lot of information displayed for each radio
button choice (how to do this easily with schemas I just don't know.
Vocabularies still make my brain hurt when I try to use them, binding
the right custom widget for some of these collection / choice type
fields is difficult, and this situation really wants a custom widget
to render this text as I want it); and one of the choices may enable
another field to show up when selected. The view behind it does a lot
of computation to figure out the current setting. This is all to
provide a drop-dead-easy security form for certain objects where a
restricted user can opt to share a particular object with an even more
restricted set of users, or keep it public. It seemed easier to use
basic HTML skills to design the UI and dedicate the view's logic to
computing the current setting and applying the user's decision. Not
having Python expressions to do a boolean test to see which radio
button to highlight wouldn't have been the end of the world, but it
would have been severely frustrating. (Figuring out all of the ways
that security and 'anonymous' access can best be granted or denied was
more than enough fun on its own, thank you).

On 12/28/05, Rocky Burt <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Please don't mistake this as a proposal or anything of the sort but I
> was just curious what the rest of the zope3 community thought on this
> particular topic.  (Please forgive me if this topic has been exhaused to
> death already)
>
> Its my personal opinion that anytime a page template requires logic
> complicated enough to warrant using a 'python:' expression, that logic
> should be re-thought and placed into a view class.  I know that some
> python: expressions are fairly simple, but for an HTML designer, *any*
> python: portions are dangerous to touch (and shouldn't be touched by the
> HTML designer).
>
> What do you all think?
>
> Regards,
> Rocky
>
>
> --
> Rocky Burt
> ServerZen Software -- http://www.serverzen.com
> ServerZen Hosting -- http://www.serverzenhosting.net
> News About The Server -- http://www.serverzen.net
>
> ___
> Zope3-dev mailing list
> Zope3-dev@zope.org
> Unsub: http://mail.zope.org/mailman/options/zope3-dev/eucci.group%40gmail.com
>
>
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-30 Thread Fred Drake
On 12/29/05, Jeff Shell <[EMAIL PROTECTED]> wrote:
> in the picture. But there are still little situations where Python
> expressions are handy, especially on big-macro templates where there's
> not a backing view. I'm not advocating programming in page templates,

This points out where change is really needed (rather than just
debated): templates used to provide macros don't have a place for
Python code.

That's a problem that's more in need of a solution than determining
whether we like python: expressions.


  -Fred

--
Fred L. Drake, Jr.
"There is no wealth but life." --John Ruskin
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-29 Thread Jeff Shell
-1.

I use them very rarely, and expect to use them less with Viewlets now
in the picture. But there are still little situations where Python
expressions are handy, especially on big-macro templates where there's
not a backing view. I'm not advocating programming in page templates,
but there are some boolean or quick-transformation (ensuring a
potential iterator/generator is a list and has length) that needs to
be done out in this phantom land.

As I mentioned above, I really believe that Viewlets and Viewlet
Managers will help with these big complex templates which provide the
look and feel of the front page or the basic template. But I know that
sometimes, when putting those pages together from a designers input on
a tight deadline with multiple browsers to test, the quick math and
other small expressions we can squeeze into those spots have been a
life-saver, even in recent weeks.

On 12/28/05, Rocky Burt <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Please don't mistake this as a proposal or anything of the sort but I
> was just curious what the rest of the zope3 community thought on this
> particular topic.  (Please forgive me if this topic has been exhaused to
> death already)
>
> Its my personal opinion that anytime a page template requires logic
> complicated enough to warrant using a 'python:' expression, that logic
> should be re-thought and placed into a view class.  I know that some
> python: expressions are fairly simple, but for an HTML designer, *any*
> python: portions are dangerous to touch (and shouldn't be touched by the
> HTML designer).
>
> What do you all think?
>
> Regards,
> Rocky
>
>
> --
> Rocky Burt
> ServerZen Software -- http://www.serverzen.com
> ServerZen Hosting -- http://www.serverzenhosting.net
> News About The Server -- http://www.serverzen.net
>
> ___
> Zope3-dev mailing list
> Zope3-dev@zope.org
> Unsub: http://mail.zope.org/mailman/options/zope3-dev/eucci.group%40gmail.com
>
>
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-29 Thread Gary Poster


On Dec 28, 2005, at 5:00 PM, Igor Stroh wrote:


Rocky Burt wrote:

...
Its my personal opinion that anytime a page template requires logic
complicated enough to warrant using a 'python:' expression, that  
logic

should be re-thought and placed into a view class.  ...


First, I have sympathy with those who want this to be a documentation  
change, possibly with a permanent default-but-configurable warning,  
rather than ripping out the feature.  I think "python:" has been  
around too long to change without a full "reinvent TAL for 2.0 or  
switch to an competing templating technology" discussion.  It's too  
much a part of standard in-the-trenches TALES usage.



+/-0
I'd give it a +1 if TAL would support boolean operators :)


Second, I agree with Igor than booleans are the time when I still  
pull out the "python:" bit of the TALES toolbox.  If we remove or  
deprecate "python:", I'd like to have a replacement.


The other replacements people have mentioned for the "python:"  
feature are list item access and calling with arguments.  I don't  
care as much about the list item access, but wouldn't object to it.   
I'm opposed to a new TAL syntax that allows calling with arguments:  
that's the core of the "python:" feature, and what many are opposed to.


Gary
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-29 Thread Andreas Jung



--On 28. Dezember 2005 17:29:11 +0100 Andreas Jung <[EMAIL PROTECTED]> 
wrote:





--On 28. Dezember 2005 11:04:09 -0500 Jim Fulton <[EMAIL PROTECTED]> wrote:


What do you all think?


+1

Views make it much easier to keep Python code in Python modules.

python expressions should be strongly discouraged in ZPT, IMO.


-0.5 - there a situations especially when prototying things when
view classes are just overhead and counterproductive.


Another argument against removing python expressions: in Zope 2 scripters 
could directly modify and test templates, script etc. (also using the skins 
tool). In Z3 you have to restart the server at least for view classes (but 
not for templates).


-aj



pgp4b3r3tr8eh.pgp
Description: PGP signature
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-29 Thread kit blake
-1, unless TAL is changed to support booleans and arguments.

I agree with Igor: the majority of Python I see in ZPTs is performing
tests. The most common use case is coloring table rows, but there are
many more, too many for generic view code to cover.

When an argument needs to be passed, it's annoying. Switching from
elegant TAL to hyper-punctuated Python is a drag :-)
kit


--
kit blake
Infrae · infrae.com · +31 10 243 7051
Hoevestraat 10 · 3033GC · Rotterdam · The Netherlands
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-29 Thread Marius Gedminas
On Wed, Dec 28, 2005 at 12:26:13PM -0330, Rocky Burt wrote:
> Its my personal opinion that anytime a page template requires logic
> complicated enough to warrant using a 'python:' expression, that logic
> should be re-thought and placed into a view class.  I know that some
> python: expressions are fairly simple, but for an HTML designer, *any*
> python: portions are dangerous to touch (and shouldn't be touched by the
> HTML designer).
> 
> What do you all think?

+0.5

It would make the developers' job harder.  I would have to bite the
bullet and write methods for all the little 'python:foo and bar'
snippets (no boolean operations in TALES).

The most difficult part will be to change expressions like

   tal:content="python:view.someMethod(arg1, arg2)"

where arg1/arg2 come from nested tal:repeats etc. You would have to
write a view method to wrap the inner objects deep inside lists of lists
of lists.

I think in the end you would get better code, and better page templates.
"Better" here means "more readable, more maintainable, less buggy,
better tested".

Marius Gedminas
-- 
Professionalism has no place in art, and hacking is art.  Software Engineering
might be science; but that's not what I do.  I'm a hacker, not an engineer.
-- jwz


signature.asc
Description: Digital signature
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread sathya
+1 a very sensible thought.  viewing TAL and python code together makes 
me squint eyed some times. Programmers have the tendency to go overboard 
with python expressions and prevention is better than cure.

Rocky Burt wrote:


Hi all,

Please don't mistake this as a proposal or anything of the sort but I
was just curious what the rest of the zope3 community thought on this
particular topic.  (Please forgive me if this topic has been exhaused to
death already)

Its my personal opinion that anytime a page template requires logic
complicated enough to warrant using a 'python:' expression, that logic
should be re-thought and placed into a view class.  I know that some
python: expressions are fairly simple, but for an HTML designer, *any*
python: portions are dangerous to touch (and shouldn't be touched by the
HTML designer).

What do you all think?

Regards,
Rocky


 




--
=
ZeOmega
Open Minds' Open Solutions
#2591 Dallas Parkway
Suite 408
Frisco TX, 75034
214-618-9880 (O)
214-975-1258 (F)
214-733-3467 (M)
http://www.zeomega.com
==


___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Stephan Richter
On Wednesday 28 December 2005 18:35, Terry Hancock wrote:
> 
> 
>
> for something that should occur in "every 5 repeats" of
> something.

If you are not using view classes for something like this, it is your own 
loss.

> There's no way that sort of things should be considered
> "business logic" -- it's just pagination or color bars or
> some such thing.

It is not. But view class logic is not or should not be business logic.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Terry Hancock
On Wed, 28 Dec 2005 12:26:13 -0330
Rocky Burt <[EMAIL PROTECTED]> wrote:
> Its my personal opinion that anytime a page template
> requires logic complicated enough to warrant using a
> 'python:' expression, that logic should be re-thought and
> placed into a view class.  I know that some python:
> expressions are fairly simple, but for an HTML designer,
> *any* python: portions are dangerous to touch (and
> shouldn't be touched by the HTML designer).
> 
> What do you all think?

-10!

I think it's a terrible idea. Why do I have to learn a new
programming syntax just to get things done in ZPT? I do
*most* expressions in Python syntax, with very few
exceptions.

The python syntax is explicit, clear, and matches the syntax
used elsewhere in the program.

Besides, there are plenty of places where it is convenient
to use simple mathematical relationships to manage
presentation, such as:




for something that should occur in "every 5 repeats" of
something.

There's no way that sort of things should be considered
"business logic" -- it's just pagination or color bars or
some such thing.


-- 
Terry Hancock ([EMAIL PROTECTED])
Anansi Spaceworks http://www.AnansiSpaceworks.com

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Igor Stroh
Rocky Burt wrote:
> Hi all,
> 
> Please don't mistake this as a proposal or anything of the sort but I
> was just curious what the rest of the zope3 community thought on this
> particular topic.  (Please forgive me if this topic has been exhaused to
> death already)
> 
> Its my personal opinion that anytime a page template requires logic
> complicated enough to warrant using a 'python:' expression, that logic
> should be re-thought and placed into a view class.  I know that some
> python: expressions are fairly simple, but for an HTML designer, *any*
> python: portions are dangerous to touch (and shouldn't be touched by the
> HTML designer).
> 
> What do you all think?

+/-0
I'd give it a +1 if TAL would support boolean operators :)
Seriously, there are situations where all you need is a trivial
AND or an OR expression, writing a view method to simply
be able to "select" a value (like in [0]) is just too much
overhead... Another use case is the passing of arguments
to a method/function/whatever - you might have a tal:repeat
where each iteration calls a view method and where just need
to supply an argument and you can't since TALs path syntax
doesn't support that (I say tal:repeat here, 'cos in other
situations you _probably_ can retrieve the value from REQUEST).

[0]: e.g. tal:define="foo python: bar and 'yes' or 'no'"

Cheers,
Igor
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Chris McDonough
I'm +1 for deprecating python: expressions in the context of views.   
But I'm not sure what "deprecate" would mean; I doubt they can go  
away entirely given the body of code that exists which uses them.


An interesting thing about python: expressions...  I've found that  
simple "python: foo['bar']" expressions are typically faster than  
their path counterparts ("foo/bar") because they are more explicit.   
This is not an argument to use them instead of path expressions, but  
I thought it was interesting regardless in a I-didn't-expect-that  
kind of way.


If there was even a small speed win in making TALES expression  
parsing faster by removing support for python: in some backwards- 
incompatible mode, that would be a *reason* to deprecate-in-code  
rather than deprecate-in-documentation.


- C

On Dec 28, 2005, at 11:04 AM, Jim Fulton wrote:


Rocky Burt wrote:

Hi all,
Please don't mistake this as a proposal or anything of the sort but I
was just curious what the rest of the zope3 community thought on this
particular topic.  (Please forgive me if this topic has been  
exhaused to

death already)
Its my personal opinion that anytime a page template requires logic
complicated enough to warrant using a 'python:' expression, that  
logic

should be re-thought and placed into a view class.  I know that some
python: expressions are fairly simple, but for an HTML designer,  
*any*
python: portions are dangerous to touch (and shouldn't be touched  
by the

HTML designer).
What do you all think?


+1

Views make it much easier to keep Python code in Python modules.

python expressions should be strongly discouraged in ZPT, IMO.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/chrism% 
40plope.com




___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Andreas Jung



--On 28. Dezember 2005 11:04:09 -0500 Jim Fulton <[EMAIL PROTECTED]> wrote:


What do you all think?


+1

Views make it much easier to keep Python code in Python modules.

python expressions should be strongly discouraged in ZPT, IMO.


-0.5 - there a situations especially when prototying things when
view classes are just overhead and counterproductive.

-aj


pgpsRpTMp3mfH.pgp
Description: PGP signature
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] RFC: abolishing python: expressions in ZPT TALES

2005-12-28 Thread Jim Fulton

Rocky Burt wrote:

Hi all,

Please don't mistake this as a proposal or anything of the sort but I
was just curious what the rest of the zope3 community thought on this
particular topic.  (Please forgive me if this topic has been exhaused to
death already)

Its my personal opinion that anytime a page template requires logic
complicated enough to warrant using a 'python:' expression, that logic
should be re-thought and placed into a view class.  I know that some
python: expressions are fairly simple, but for an HTML designer, *any*
python: portions are dangerous to touch (and shouldn't be touched by the
HTML designer).

What do you all think?


+1

Views make it much easier to keep Python code in Python modules.

python expressions should be strongly discouraged in ZPT, IMO.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com