开发者

Python Plone Passing Data

What I want to do is use a form gen form that calls a custom script adapter. The script will then take the search field and mess with it and plug it into an sql method called sms that searches a mysql database. All I need to figure out is how to display the results in a page.

here is the script so far

  
#  ploneformgen = PloneFormGen object
request = container.REQUEST
form = request.form
RESPONSE = re开发者_JS百科quest.RESPONSE
if form.has_key('string-1') and form.has_key('form.submitted'):
    srch=form['search-1'], "%s" %'\%' 
    context.sms(srch)

I need the results of context.sms() to be formatted and passed to a page template or somthing.

I used the traverse_to:string: method once to get a custom page template to appear after but I dont know how to pass my own data in.


I used the traverse_to:string: method once to get a custom page template to 
appear after but I dont know how to pass my own data in.

Inside your template you can call arbitrary scripts (or other callable code like browser views) in general through acquisition. If your code is located inside a script foo then use something like

<tal:def define="result context/foo">

  <div tal:content="result/data1" />
  <div tal:content="result/data2" />

</tal:foo>

Inside the implementation of the foo script you just have to return the data that you need in the template. Usually you may return a dict e.g. with keys data1 or data2 holding the values to be rendered.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜