witten
/
luminotes
Archived
1
0
Fork 0

Bug fix: Clear the memcache, search for notes in an main notebook (as the

anonymous user), open a search result from a notebook. Then, login and try to
edit that notebook as a user with read-write privileges. it will show up as
read-only, presumably because it's being read from the cache.
This commit is contained in:
Dan Helfman 2008-05-19 23:43:33 -07:00
parent ae5c911c1c
commit 953f572b20
2 changed files with 18 additions and 7 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
1.3.35: May 19, 2008
* Potential fix for bug where caching of Notebook objects can cause
read-write notebooks to display as read-only.
1.3.34: May 19, 2008
* Improved performance of searching multiple notebooks.

View File

@ -6,6 +6,7 @@ import psycopg2 as psycopg
from psycopg2.pool import PersistentConnectionPool
import random
from model.Persistent import Persistent
from model.Notebook import Notebook
class Connection_wrapper( object ):
@ -21,6 +22,9 @@ class Database( object ):
ID_BITS = 128 # number of bits within an id
ID_DIGITS = "0123456789abcdefghijklmnopqrstuvwxyz"
# caching Notebooks causes problems because different users have different read_write/owner values
CLASSES_NOT_TO_CACHE = ( Notebook, )
def __init__( self, connection = None, cache = None, host = None, ssl_mode = None ):
"""
Create a new database and return it.
@ -103,7 +107,10 @@ class Database( object ):
else:
cursor.execute( obj.sql_create() )
cache = self.__get_cache_connection()
if isinstance( obj, self.CLASSES_NOT_TO_CACHE ):
cache = None
else:
cache = self.__get_cache_connection()
if commit:
connection.commit()
@ -145,10 +152,10 @@ class Database( object ):
@rtype: Object_type or NoneType
@return: loaded object, or None if no match
"""
if revision is None:
cache = self.__get_cache_connection()
else:
if revision or Object_type in self.CLASSES_NOT_TO_CACHE:
cache = None
else:
cache = self.__get_cache_connection()
if cache: # don't bother caching old revisions
obj = cache.get( Persistent.make_cache_key( Object_type, object_id ) )
@ -175,10 +182,10 @@ class Database( object ):
@rtype: Object_type or NoneType
@return: loaded object, or None if no match
"""
if use_cache:
cache = self.__get_cache_connection()
else:
if not use_cache or Object_type in self.CLASSES_NOT_TO_CACHE:
cache = None
else:
cache = self.__get_cache_connection()
if cache:
cache_key = sha.new( sql_command ).hexdigest()