Make parts of SyncUserSession more readable
This commit is contained in:
parent
bdcbb9eced
commit
8195e58e3b
@ -264,17 +264,16 @@ class SyncUserSession(object):
|
|||||||
self.path = path
|
self.path = path
|
||||||
self.collection_manager = collection_manager
|
self.collection_manager = collection_manager
|
||||||
self.setup_new_collection = setup_new_collection
|
self.setup_new_collection = setup_new_collection
|
||||||
self.version = 0
|
self.version = None
|
||||||
self.client_version = ''
|
self.client_version = None
|
||||||
self.created = time.time()
|
self.created = time.time()
|
||||||
|
self.collection_handler = None
|
||||||
|
self.media_handler = None
|
||||||
|
|
||||||
# make sure the user path exists
|
# make sure the user path exists
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
self.collection_handler = None
|
|
||||||
self.media_handler = None
|
|
||||||
|
|
||||||
def _generate_session_key(self):
|
def _generate_session_key(self):
|
||||||
return checksum(str(random.random()))[:8]
|
return checksum(str(random.random()))[:8]
|
||||||
|
|
||||||
@ -286,13 +285,13 @@ class SyncUserSession(object):
|
|||||||
|
|
||||||
def get_handler_for_operation(self, operation, col):
|
def get_handler_for_operation(self, operation, col):
|
||||||
if operation in SyncCollectionHandler.operations:
|
if operation in SyncCollectionHandler.operations:
|
||||||
cache_name, handler_class = 'collection_handler', SyncCollectionHandler
|
attr, handler_class = 'collection_handler', SyncCollectionHandler
|
||||||
else:
|
else:
|
||||||
cache_name, handler_class = 'media_handler', SyncMediaHandler
|
attr, handler_class = 'media_handler', SyncMediaHandler
|
||||||
|
|
||||||
if getattr(self, cache_name) is None:
|
if getattr(self, attr) is None:
|
||||||
setattr(self, cache_name, handler_class(col))
|
setattr(self, attr, handler_class(col))
|
||||||
handler = getattr(self, cache_name)
|
handler = getattr(self, attr)
|
||||||
# The col object may actually be new now! This happens when we close a collection
|
# The col object may actually be new now! This happens when we close a collection
|
||||||
# for inactivity and then later re-open it (creating a new Collection object).
|
# for inactivity and then later re-open it (creating a new Collection object).
|
||||||
handler.col = col
|
handler.col = col
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user