[Zope] Displaying SQL results correctly

Dieter Maurer dieter at handshake.de
Thu Nov 25 14:37:02 EST 2004


Dean Hale wrote at 2004-11-25 11:13 +0000:
>I'm extracting content from a database which contains several numbers 
>for example 72, 354. Each number is separated by commas. The numbers 
>correspond to other id's within the table.
>
>I'm using below which kind of works however the url is specified as
>
>http://157.228.32.93:9191/education/nug_db/detail_html?id=72,%20354

Note that the use of "%20" (this is a blank) is forbidden
in query strings. In query strings, blank must be coded as "+".

> ...
>CourseLike is the field which corrospond to other ID's - 72, 354
>CourseTitle is the course title
>
><a href="" tal:define="CourseLike result/CourseLike" 
>tal:attributes="href
>string:detail_html?id=$CourseLike" tal:content="result/CourseTitle" 
>target="_blank">
><span tal:replace="result/CourseTitle">CourseTitle
>         goes here</span></a>
>
>i'd like each id to be repeated separately rather than in the one long 
>url.

I have problems to understand what you want...

  When you repeat the ids separately, the URL will become longer...

  Repeating separately would look like:

	tal:define="
	  ...
	  ids result/CourseLike;
	  repeatedIds python:'&'.join(['id:list=%s' % id for id in ids]);
	  ...
	  "
	  >...
	    tal:attributes="href string:detail_html?$ids"

The code above assumes that "result/CourseLike" returns a
sequence of ids. If instead it returns a string, it will
need to be split at its element separator (apparently ", ") to
obtain a list of ids.

-- 
Dieter


More information about the Zope mailing list