[Twisted-web] adbapi/Nevow Question

orbitz orbitz at ezabel.com
Wed Dec 29 12:39:52 MST 2004

You define a data method, and for that data you tell it to use the 
sequence renderer.  Your data method will just perform the query and 
return it as a result (nevow handles deferreds properly).  Then in your 
table for each row you simply tell that row to use the index in the data 
which you want in there. 0, 1, 2, etc. The only issue may be what 
db-api2 module you are using. pyscopg for postgresql works well, 
otherwise you'll get a cannot adapt error or something like that.
Here is an example with xmlfile:

  def data_departments(self, context, data):
    db = DatabaseConnection()
    return db.runQuery("""SELECT did, name FROM departments""")

<select name = "department" nevow:data = "departments" nevow:render = 
<option nevow:pattern = "header" value = "depsel" selected 
="selected">Select Department</option>
<option nevow:pattern = "item"><nevow:attr name = "value" nevow:render = 
"string" nevow:data = "0"/>
<nevow:invisible nevow:render = "string" nevow:data = "1"/> </option>

Ed Suominen wrote:

>Using twisted.enterprise.adbapi and Nevow, I am rendering a big table of 
>entries from one SQL table, each of which has table cells that can 
>contain multiple entries from another SQL table. I have some stan code 
>working for the top-level entries with a top-level 
>render=directive("sequence"), but am wondering how to go about 
>rendering the table-within-a-cell for the second-level entries. 
>Can sequence directives be nested, or would I have to manually run the 
>second-level SQL queries in some sort of fire-and-wait-for-the-deferred 
>iteration from within the render_ method of the top-level sequence? The 
>latter sounds like it would be very difficult to keep from blocking.
>Thanks for any help. I am finding Nevow to be fascinating and powerful, 
>but very difficult to understand and use.
>-Ed Suominen
>Twisted-web mailing list
>Twisted-web at twistedmatrix.com

More information about the Twisted-web mailing list