# HG changeset patch # User fabien@tzone.org # Date 1230700045 18000 # Node ID d79722064d8d044349d7b0096b662e033a5ec0f0 # Parent c1f1491f098cf7f9dd50cd7520a151fa88bf1000# Parent a0aa025ee6a205f8a4f9352729e7d9782c1d5bc5 Merge previous changeset and ensure everything seems to work. diff -r a0aa025ee6a2 -r d79722064d8d ChangeLog --- a/ChangeLog Tue Dec 30 23:16:05 2008 -0500 +++ b/ChangeLog Wed Dec 31 00:07:25 2008 -0500 @@ -1,3 +1,10 @@ +xbelweb (0.1-7) unstable; urgency=low + + * Rewrite the architecture completely with cleaner separation and + common entry-point. + + -- Fabien Ninoles Sun, 28 Dec 2008 15:05:51 -0500 + xbelweb (0.1-6) unstable; urgency=low * Optimization of get_bookmarks_count which was call too often. diff -r a0aa025ee6a2 -r d79722064d8d INSTALL --- a/INSTALL Tue Dec 30 23:16:05 2008 -0500 +++ b/INSTALL Wed Dec 31 00:07:25 2008 -0500 @@ -31,15 +31,16 @@ 1. Move the python code into a repertory where the web server will serve the CGI. -2. Tell the web server to serve only CGI .py from the root directory - of the application. The lib and templates directory content should not - be used. Add any authorization you need. +2. Tell the web server to serve only CGI .py from the root directory of + the application. The lib and templates directory content should not be + used. tests neither and can even be removed. Add any authorization you + need. 3. Create a database for xbelweb (e.g., "xbelweb"), then create the tables in the database used by xbelweb using the ./lib/db/create_db.[your database] definition. I do it with psql -U php < create_db.postgresql -4. Update the lib/config.py file to reflect your db configuration. +4. Copy index.py.ex to index.py and edit the necessary information. diff -r a0aa025ee6a2 -r d79722064d8d TODO --- a/TODO Tue Dec 30 23:16:05 2008 -0500 +++ b/TODO Wed Dec 31 00:07:25 2008 -0500 @@ -1,5 +1,5 @@ +* Add test unit. * Add licences notes to src files. -* Make it a stateless with single entry point wellform CGI program. * Add synonymous support. * Add "new keyword" enlighting, maybe with link to keyword editing. * Add similar keywords suggestions. Otherly said: "Bookmarks which have diff -r a0aa025ee6a2 -r d79722064d8d index.py --- a/index.py Tue Dec 30 23:16:05 2008 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#!/usr/bin/python - -import sys -import traceback -if (__name__ == '__main__'): - sys.path.insert(0, "/home/fabien/lib/python") - sys.path.insert(0, "./lib") - sys.stderr = sys.stdout - - print "Content-type: text/html; charset=iso-8859-1;" - print - -# import cgitb; cgitb.enable() -import cgi -import my_db - -from local_config import CONFIG -from os import environ -from actions import actions - -if (__name__ == "__main__"): - form = cgi.FieldStorage() - if form.has_key('debug'): - sys.stderr = sys.stdout - print "
"
-    db = my_db.connect(CONFIG, environ["REMOTE_USER"])
-    prefs = db.get_preferences()
-    if form.has_key('action'):
-    	action = form['action'].value
-    else:
-    	action = 'default'
-    if action in actions.keys():
-    	actions[action](action, db, prefs, form)
-    else:
-    	actions['default']('default', db, prefs, form)
-    print "
" diff -r a0aa025ee6a2 -r d79722064d8d index.py.ex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.py.ex Wed Dec 31 00:07:25 2008 -0500 @@ -0,0 +1,18 @@ +#!/usr/bin/python + +if (__name__ == '__main__'): + import sys + sys.path.insert(0, "./lib") + +from config import CONFIG + +CONFIG.db_name = 'database_name' +CONFIG.db_user = 'my_user' +CONFIG.db_host = 'db.host.com' +CONFIG.db_passwd = 'secr3t.passwd' +# CONFIG.db_port = 5432 + +import xbelweb + +if (__name__ == "__main__"): + xbelweb.main() diff -r a0aa025ee6a2 -r d79722064d8d lib/templates.py --- a/lib/templates.py Tue Dec 30 23:16:05 2008 -0500 +++ b/lib/templates.py Wed Dec 31 00:07:25 2008 -0500 @@ -1,7 +1,7 @@ from htmltmpl import TemplateManager, TemplateProcessor from urlparse import urljoin from os import environ, path -from config import template_dir +from config import CONFIG def get_curl(): url = "http" @@ -15,7 +15,7 @@ class Template: def __init__(self, template, prefs, status = "msg", status_msg = ""): self.tproc = TemplateProcessor() - self.tmpl = TemplateManager().prepare(path.join(template_dir, template)) + self.tmpl = TemplateManager().prepare(path.join(CONFIG.template_dir, template)) self.set("remote_user", prefs["fullname"]) self.set("kw_size", prefs['keywords_box']) self.set("kw_sort", prefs['keywords_sort']) diff -r a0aa025ee6a2 -r d79722064d8d lib/xbelweb.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/xbelweb.py Wed Dec 31 00:07:25 2008 -0500 @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import sys +import cgi +import my_db +from os import environ +from actions import actions +from config import CONFIG + +def main(): + sys.stderr = sys.stdout + print "Content-type: text/html; charset=iso-8859-1;" + print + form = cgi.FieldStorage() + debug = form.has_key('debug') + if debug: + sys.stderr = sys.stdout + print "
"
+    db = my_db.connect(CONFIG, environ["REMOTE_USER"])
+    prefs = db.get_preferences()
+    if form.has_key('action'):
+    	action = form['action'].value
+    else:
+    	action = 'default'
+    if action in actions.keys():
+    	actions[action](action, db, prefs, form)
+    else:
+    	actions['default']('default', db, prefs, form)
+    if debug:
+    	print "
"