[Zope] crazy result
J. Cameron Cooper
jccooper at jcameroncooper.com
Wed Dec 3 22:54:38 EST 2003
Kate Legere wrote:
>This is insane ... I have an example (using DTML) of this working perfectly
>and an example (using TAL) where it doesn't work at all:
>
>I have a DTML method which is a form that allows users to add their name
>(staff_name), some text (description) and a link (link_url)
>
><p>Details: <br>
> <textarea name="description" rows="10" cols="60"></textarea>
></p>
>
>---
>on submit it calls a DTML method named addEntryAction which calls a python
>method 'add'
>
><dtml-call expr="add(staff_name, link_url, description)">
>
>---
>the python method creates a file and adds the description (and the other
>parameters)
>
># create a unique file id
>id='message_%d' % len(context.objectIds())
>
># create the document
>context.manage_addProduct['OFSP'].manage_addFile(id,
> title="", file=description)
>
>-----
>then you get booted back to the page that iterates through all the postings.
>this is a TAL file called index.html
>
> <span tal:condition="python: item.meta_type == 'File'">
> <b tal:content="item/staff_name"> name
> </b>
> wrote on
>
> <span tal:define="mtime item/bobobase_modification_time"
> tal:content="python:mtime.strftime('%d/%m/%Y
>%H:%M')">date
> </span>
>
> and added the link: <b
>tal:content="item/link_url">link</b><br>
> saying
>
> <b tal:define="pss modules/Products/PythonScripts/standard"
> tal:content="python: pss.newline_to_br(item.description)">
>news
> </b>
> <hr>
> </span>
>
>------
>Everything works and displays except description which displays as the word
>description. When I add an item and then go back and look at the file
>created - the text is always 'description' no matter what I typed.
>
>What's going on here???
>
Got me. In fact, it's so strange I'll even allow the three question
marks. Everything looks right to me, though I can't see the parameter
list for your Python script. Seems like you've got a default of
'description' that's being applied or a literal of the same being passed
in somewhere. But I don't see any of these.
So: narrow it down a bit. Print the request object in the method to
which you submit the form. Print the value of 'description' in the
Python script. Hardcode values in along the chain and see where things
change. Change the names of parameters and variables to make sure you're
spelling everything right. Put in a 'span' with
'tal:replace="item/description"' to rule out the TAL statement.
Also, why the intermediate DTML method? Unless it does something I can't
see, submit straight to the Python script and return or redirect to the
final page from there. If you never see anything rendered by it, a DTML
method has absolutely no reason to exist.
--jcc
--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."
More information about the Zope
mailing list