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:
parent
ae5c911c1c
commit
953f572b20
4
NEWS
4
NEWS
|
@ -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
|
1.3.34: May 19, 2008
|
||||||
* Improved performance of searching multiple notebooks.
|
* Improved performance of searching multiple notebooks.
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import psycopg2 as psycopg
|
||||||
from psycopg2.pool import PersistentConnectionPool
|
from psycopg2.pool import PersistentConnectionPool
|
||||||
import random
|
import random
|
||||||
from model.Persistent import Persistent
|
from model.Persistent import Persistent
|
||||||
|
from model.Notebook import Notebook
|
||||||
|
|
||||||
|
|
||||||
class Connection_wrapper( object ):
|
class Connection_wrapper( object ):
|
||||||
|
@ -21,6 +22,9 @@ class Database( object ):
|
||||||
ID_BITS = 128 # number of bits within an id
|
ID_BITS = 128 # number of bits within an id
|
||||||
ID_DIGITS = "0123456789abcdefghijklmnopqrstuvwxyz"
|
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 ):
|
def __init__( self, connection = None, cache = None, host = None, ssl_mode = None ):
|
||||||
"""
|
"""
|
||||||
Create a new database and return it.
|
Create a new database and return it.
|
||||||
|
@ -103,7 +107,10 @@ class Database( object ):
|
||||||
else:
|
else:
|
||||||
cursor.execute( obj.sql_create() )
|
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:
|
if commit:
|
||||||
connection.commit()
|
connection.commit()
|
||||||
|
@ -145,10 +152,10 @@ class Database( object ):
|
||||||
@rtype: Object_type or NoneType
|
@rtype: Object_type or NoneType
|
||||||
@return: loaded object, or None if no match
|
@return: loaded object, or None if no match
|
||||||
"""
|
"""
|
||||||
if revision is None:
|
if revision or Object_type in self.CLASSES_NOT_TO_CACHE:
|
||||||
cache = self.__get_cache_connection()
|
|
||||||
else:
|
|
||||||
cache = None
|
cache = None
|
||||||
|
else:
|
||||||
|
cache = self.__get_cache_connection()
|
||||||
|
|
||||||
if cache: # don't bother caching old revisions
|
if cache: # don't bother caching old revisions
|
||||||
obj = cache.get( Persistent.make_cache_key( Object_type, object_id ) )
|
obj = cache.get( Persistent.make_cache_key( Object_type, object_id ) )
|
||||||
|
@ -175,10 +182,10 @@ class Database( object ):
|
||||||
@rtype: Object_type or NoneType
|
@rtype: Object_type or NoneType
|
||||||
@return: loaded object, or None if no match
|
@return: loaded object, or None if no match
|
||||||
"""
|
"""
|
||||||
if use_cache:
|
if not use_cache or Object_type in self.CLASSES_NOT_TO_CACHE:
|
||||||
cache = self.__get_cache_connection()
|
|
||||||
else:
|
|
||||||
cache = None
|
cache = None
|
||||||
|
else:
|
||||||
|
cache = self.__get_cache_connection()
|
||||||
|
|
||||||
if cache:
|
if cache:
|
||||||
cache_key = sha.new( sql_command ).hexdigest()
|
cache_key = sha.new( sql_command ).hexdigest()
|
||||||
|
|
Reference in New Issue