Attachment 'dbadapter.py'

Download

   1 import MySQLdb
   2 import traceback, sets
   3 
   4 regex = r".*"
   5 dbpages = sets.Set()
   6 hdpages = sets.Set()
   7 
   8 conn = MySQLdb.connect(host = "localhost", user = "root", passwd = "", db = "wp")
   9 
  10 def convPagename(pn):
  11     return conn.escape(pn.encode("iso-8859-1", "replace").replace(" ", "_"))
  12     
  13 def filter(pagename, mo): # set frontpage FIXME
  14     if pagename in ("", "FrontPage", "StartSeite") or pagename in hdpages:
  15         return False
  16     if pagename in dbpages:
  17         return True
  18     cursor = conn.cursor()
  19     rows = cursor.execute("SELECT 1 FROM cur WHERE cur_title = " + convPagename(pagename))
  20     cursor.close()
  21     if (rows > 0):
  22         dbpages.add(pagename)
  23         return True
  24     else:
  25         hdpages.add(pagename)
  26         return False
  27 
  28 def execute(request, match):
  29     print "Fetching " + request.page.page_name
  30     #traceback.print_stack()
  31     cursor = conn.cursor()
  32     cursor.execute("SELECT cur_text FROM cur WHERE cur_title = " + convPagename(request.page.page_name))
  33     row = cursor.fetchone()
  34     if row is not None:
  35         text = row[0]
  36     else:
  37         text = "Page not found."
  38     cursor.close()
  39     return text

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-05-04 19:48:39, 1.1 KB) [[attachment:dbadapter.py]]
  • [get | view] (2005-05-21 22:11:19, 135.2 KB) [[attachment:moinpedia.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.