Re: getting openid comments to work

Peter Meerwald <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hello,

> Can you send us patches?  That'd make it a lot easier to get these things 
> done.  Otherwise you're at the mercy of finding free time.

attached are patches against the individual files

comments-patch.txt applies against comments.py from trunk

session-lock-patch.txt applies against
http://www.c-area.ch/code/pyblosxom/plugins/session.py

openid-complete-patch.txt applies against
http://snarfed.org/space/comments_openid.py

>> I set up pyblosxom with the openid_server and openid_comment plugin and ran 
>> into a couple of issues:
>> 
>> 1. if an OpenID request is handled, cmtExpr() in comments.py breaks because 
>> entry['absolute_path'] and entry['fn'] both return None and the code 
>> subsequently fails when using the None values;
>> so I added a check to just return in case None is returned
>> 
>> 2. the locking code in session.py is broken, ie. _lock() and _unlock(); if 
>> the file to lock does not (yet) exist, an exception is thrown; I suggest to 
>> use exception handlers within these methods
>> 
>> 3. comments_openid.py only passed one parameter to consumer.complete() in 
>> complete_openid_auth(), however, newer python-openid libraries require a 
>> second parameter; this can be easily fixed with the following line
>> 
>> # Ask the OpenID library to check the server's response
>> response = consumer.complete(query, return_to)

regards, p.

-- 

Peter Meerwald
Kaigasse 3 / 8
A-5020 Salzburg / AUSTRIA
+43-664-2444418 (mobile)

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
session-lock-patch.txt (text/plain, 1.1 KB)
--- orig/session.py	2008-04-22 19:28:36.000000000 +0200
+++ new/session.py	2008-04-22 19:26:11.000000000 +0200
@@ -230,18 +230,24 @@
 
     def _lock(self):
         # ???: does this work as expected?
-        if self._use_lock:
-            self._dbmfile_lock = open(self._dbmfile, "r+")
-            tools.lock(self._dbmfile_lock, tools.LOCK_EX)
-            self._locked = 1
+        try:
+            if self._use_lock:
+                self._dbmfile_lock = open(self._dbmfile, "r+")
+                tools.lock(self._dbmfile_lock, tools.LOCK_EX)
+                self._locked = 1
+        except: 
+                pass
 
 
     def _unlock(self):
         # ???: does this work as expected?
-        if self._use_lock and self._locked:
-            tools.unlock(self._dbmfile_lock)
-            self._dbmfile_lock.close()
-            self._locked = 0
+        try:
+            if self._use_lock and self._locked:
+               tools.unlock(self._dbmfile_lock)
+               self._dbmfile_lock.close()
+               self._locked = 0
+        except: 
+                pass
 
 
     def _getDBM(self):
openid-complete-patch.txt (text/plain, 1 KB)
--- orig/comments_openid.py	2008-04-22 19:31:09.000000000 +0200
+++ new/comments_openid.py	2008-04-22 19:32:36.000000000 +0200
@@ -121,7 +121,7 @@
 
     try:
         import_and_initialize()
-        get_openid_consumer()
+        get_openid_consumer(request)
     except:
         print "Error initializing OpenID libraries."
         retval = 0
@@ -169,7 +169,7 @@
         raise
 
 
-def get_openid_consumer(request, session):
+def get_openid_consumer(request, session=None):
     """Initialize an OpenID store for authenticating comments.
 
     @param request: Pyblosxom request object
@@ -356,7 +356,7 @@
             raise OpenIDCommentError('Error handling OpenID response')
 
         # Ask the OpenID library to check the server's response
-        response = consumer.complete(query)
+        response = consumer.complete(query, return_to)
         if response.status == openid.SUCCESS:
             if response.identity_url is None:
                 raise OpenIDCommentError('OpenID authentication cancelled')
comments-patch.txt (text/plain, 492 B)
--- orig/comments.py	2008-04-22 19:27:23.000000000 +0200
+++ new/comments.py	2008-04-22 19:37:02.000000000 +0200
@@ -330,6 +330,9 @@
     
     @returns: a string containing the regular expression for comment entries
     """
+    if entry['absolute_path'] == None or entry['fn'] == None:
+        return ''
+
     cmtDir = os.path.join(config['comment_dir'], entry['absolute_path'])
     cmtExpr = os.path.join(cmtDir,entry['fn']+'-*.'+config['comment_ext'])
     return cmtExpr
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.