Re: [Zope] Python/TAL Problem

2006-07-25 Thread Peter Bengtsson

Guess guess, do all objects have the 'KW1' property? I don't think so.
Try this:

  div tal:define=blankstring string:
 input type=text name=rows.title:records size=50
tal:attributes=value python:item/KW1|blankstring /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/KW1|blankstring /
  /div

beno wrote:

Hi;
I'm trying to tweak someone else' script to get it to do what I want. 
The script reads from and writes to the Properties tab of pages and 
folders, enabling one to change the titles of many pages/folders from 
one single script-generated page. I want to be able to do the same thing 
with another field I created called KW1 (string) in the Properties 
tab. The following is a snip of the code that needs to be altered (the 
only code where title appears):


 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /

If I alter line #2 and change title to KW1 I get the following error 
snippet:


   * Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
 __traceback_info__: item['KW1']
   * Module Python expression item['KW1'], line 1, in expression
   * Module AccessControl.ZopeGuards, line 67, in guarded_getitem

If I alter line #4 and change title to KW1 I get this error snippet:

   * Module Products.PageTemplates.Expressions, line 174, in __call__
   * Module Products.PageTemplates.Expressions, line 162, in _eval
   * Module Products.PageTemplates.Expressions, line 116, in _eval
 __traceback_info__: item
   * Module Products.PageTemplates.Expressions, line 320, in
 restrictedTraverse
 __traceback_info__: {'path': ['KW1'], 'TraversalRequestNameStack': []}

I have added KW1 as a string property to many of the pages in the target 
folder. What am I doing wrong? Complete code and complete errors follow.

Thanks.








COMPLETE SCRIPT

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html tal:condition=here/formHandler

!--
script type=text/javascript src=main.js/script
--

body

h1Manage Hierarchy/h1


form action= method=post name=form id=form
 tal:define=root python:request.fields['root'];
 items python:root['value'] and 
sequence.sort(here.getEntries(root['value'], all=1), (('id', 'cmp', 
'desc'),))



div id=filter
 select name=root
 tal:define=items python:here.getEntries('en-us', 2)
option value=#8212;#8212;Select 
Folder#8212;#8212;/option

   option tal:repeat=item items
   tal:content=structure python:'%s\--%s' % 
('nbsp;'*5*item['level'], item['id'])

   tal:attributes=value python:item['url'];
   selected python:item['url'] == root['value']
   /option
 /select
 input type=submit name=onOk value=Ok /
/div



div id=resultSet
 table cellspacing=0 cellpadding=3 border=1
tal:condition=items
 tr
   thID/th
   thKW1/th
 /tr
 tr valign=top
 tal:repeat=item items
   td
 span tal:replace=structure python:'nbsp;' * (8 * item['level']) 
+ item['id']ID/span

 input type=hidden name=rows.id:records
tal:attributes=value python:item['url'] /
   /td
   td
 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /
   /td
 /tr
 /table

 div tal:condition=python:not items
   Sorry... no items to manage.br /
 /div
/div




div id=buttons
 input type=submit name=onSaveChanges value= Save Changes 
tal:condition=items /
/div

/form


/body
/html





FIRST ERROR MESSAGE
from changing  tal:attributes=value python:item['title'] 
/  total:attributes=value python:item['KW1'] /



   Site Error

An error was encountered while publishing this resource.

*KeyError*

Sorry, a site error occurred.

Traceback (innermost last):

   * Module ZPublisher.Publish, line 175, in publish_module_standard
   * Module ZPublisher.Publish, line 132, in publish
   * Module Zope.App.startup, line 204, in zpublisher_exception_hook
   * Module ZPublisher.Publish, line 101, in publish
   * Module ZPublisher.mapply, line 88, in mapply
   * Module ZPublisher.Publish, line 39, in call_object
   * Module Shared.DC.Scripts.Bindings, line 306, in __call__
   * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
   * Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec
   * Module Products.PageTemplates.PageTemplate, line 96, in pt_render
 *ZopePageTemplate at /footprints.2012.vi/test_kw/main/index_html*
   * Module TAL.TALInterpreter, line 190, in __call__
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 637, in do_condition
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module 

[Zope] Python/TAL Problem

2006-07-22 Thread beno

Hi;
I'm trying to tweak someone else' script to get it to do what I want. 
The script reads from and writes to the Properties tab of pages and 
folders, enabling one to change the titles of many pages/folders from 
one single script-generated page. I want to be able to do the same thing 
with another field I created called KW1 (string) in the Properties 
tab. The following is a snip of the code that needs to be altered (the 
only code where title appears):


 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /

If I alter line #2 and change title to KW1 I get the following error 
snippet:


   * Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__
 __traceback_info__: item['KW1']
   * Module Python expression item['KW1'], line 1, in expression
   * Module AccessControl.ZopeGuards, line 67, in guarded_getitem

If I alter line #4 and change title to KW1 I get this error snippet:

   * Module Products.PageTemplates.Expressions, line 174, in __call__
   * Module Products.PageTemplates.Expressions, line 162, in _eval
   * Module Products.PageTemplates.Expressions, line 116, in _eval
 __traceback_info__: item
   * Module Products.PageTemplates.Expressions, line 320, in
 restrictedTraverse
 __traceback_info__: {'path': ['KW1'], 'TraversalRequestNameStack': []}

I have added KW1 as a string property to many of the pages in the target 
folder. What am I doing wrong? Complete code and complete errors follow.

Thanks.








COMPLETE SCRIPT

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html tal:condition=here/formHandler

!--
script type=text/javascript src=main.js/script
--

body

h1Manage Hierarchy/h1


form action= method=post name=form id=form
 tal:define=root python:request.fields['root'];
 items python:root['value'] and 
sequence.sort(here.getEntries(root['value'], all=1), (('id', 'cmp', 
'desc'),))



div id=filter
 select name=root
 tal:define=items python:here.getEntries('en-us', 2)
 
   option value=#8212;#8212;Select Folder#8212;#8212;/option

   option tal:repeat=item items
   tal:content=structure python:'%s\--%s' % 
('nbsp;'*5*item['level'], item['id'])

   tal:attributes=value python:item['url'];
   selected python:item['url'] == root['value']
   /option
 /select
 input type=submit name=onOk value=Ok /
/div



div id=resultSet
 table cellspacing=0 cellpadding=3 border=1
tal:condition=items
 tr
   thID/th
   thKW1/th
 /tr
 tr valign=top
 tal:repeat=item items
   td
 span tal:replace=structure python:'nbsp;' * (8 * item['level']) 
+ item['id']ID/span

 input type=hidden name=rows.id:records
tal:attributes=value python:item['url'] /
   /td
   td
 input type=text name=rows.title:records size=50
tal:attributes=value python:item['title'] /
 input type=hidden name=prev_rows.title:records
tal:attributes=value item/title /
   /td
 /tr
 /table

 div tal:condition=python:not items
   Sorry... no items to manage.br /
 /div
/div




div id=buttons
 input type=submit name=onSaveChanges value= Save Changes 
tal:condition=items /
/div

/form


/body
/html





FIRST ERROR MESSAGE
from changing  tal:attributes=value python:item['title'] 
/  total:attributes=value python:item['KW1'] /



   Site Error

An error was encountered while publishing this resource.

*KeyError*

Sorry, a site error occurred.

Traceback (innermost last):

   * Module ZPublisher.Publish, line 175, in publish_module_standard
   * Module ZPublisher.Publish, line 132, in publish
   * Module Zope.App.startup, line 204, in zpublisher_exception_hook
   * Module ZPublisher.Publish, line 101, in publish
   * Module ZPublisher.mapply, line 88, in mapply
   * Module ZPublisher.Publish, line 39, in call_object
   * Module Shared.DC.Scripts.Bindings, line 306, in __call__
   * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
   * Module Products.PageTemplates.ZopePageTemplate, line 222, in _exec
   * Module Products.PageTemplates.PageTemplate, line 96, in pt_render
 *ZopePageTemplate at /footprints.2012.vi/test_kw/main/index_html*
   * Module TAL.TALInterpreter, line 190, in __call__
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 637, in do_condition
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 637, in do_condition
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 613, in do_loop_tal
   * Module TAL.TALInterpreter, line 234, in interpret
   * Module TAL.TALInterpreter, line 263, in do_startEndTag
   * Module TAL.TALInterpreter, line 291, in do_startTag
   * Module TAL.TALInterpreter, line 357,