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
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""") <p> <select name = "department" nevow:data = "departments" nevow:render = "sequence"> <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> </select></p> 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@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (2)
-
Ed Suominen
-
orbitz