Skip to content

Commit

Permalink
add method delete #139
Browse files Browse the repository at this point in the history
  • Loading branch information
serg0987 committed Aug 15, 2011
1 parent 18a994c commit a1e0e94
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datastore.py
Expand Up @@ -137,14 +137,21 @@ def get_values(self):
def get(cls, id, storage = None): # storage=None for backword capability
"Get object from Redis storage by ID"
# First try to find object by Id
# example: gameserver:scratchgames:101
inst_data = RedisConn.get(':'.join([REDIS_NAMESPACE, cls.get_collection_name(), str(id)]))
if not inst_data: # No objects with such ID
raise DoesNotExist('No model in Redis srorage with such id')
else:
# Copy structure of Class to new dictionary
instance_dict = json.loads(inst_data.__str__())
return cls(valuedict = instance_dict)


@classmethod
def delete(cls, id, storage = None): # storage=None for backword capability
"Delete key specified by ``id``"
result = RedisConn.delete(':'.join([REDIS_NAMESPACE, cls.get_collection_name(), str(id)]))
logging.debug('delete::______________ %s'%result)
return result

class Node(Value):
" Use it for embedd objects to model "
Expand Down

0 comments on commit a1e0e94

Please sign in to comment.