Skip to content

Instantly share code, notes, and snippets.

@jun66j5
Created January 2, 2012 14:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jun66j5/1550894 to your computer and use it in GitHub Desktop.
fieldtooltip: Parameter passing in Database API
Index: fieldtooltip/fieldtooltip.py
===================================================================
--- fieldtooltip/fieldtooltip.py (revision 11088)
+++ fieldtooltip/fieldtooltip.py (working copy)
@@ -51,10 +51,11 @@
pages = {}
cursor = db.cursor()
wiki_pages = WikiSystem(self.env).get_pages(FieldTooltip._wiki_prefix)
+ prefix_len = len(FieldTooltip._wiki_prefix)
for page in wiki_pages:
- cursor.execute("SELECT text FROM wiki WHERE name = '%s' ORDER BY version DESC LIMIT 1" % page)
+ cursor.execute("SELECT text FROM wiki WHERE name = %s ORDER BY version DESC LIMIT 1", (page,))
for text, in cursor:
- pages[page[len(FieldTooltip._wiki_prefix):]] = text
+ pages[page[prefix_len:]] = text
return pages
# ITemplateStreamFilter methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment