| Index: third_party/gsutil/boto/boto/sdb/db/sequence.py
|
| diff --git a/third_party/gsutil/20110627/boto/boto/sdb/db/sequence.py b/third_party/gsutil/boto/boto/sdb/db/sequence.py
|
| similarity index 93%
|
| rename from third_party/gsutil/20110627/boto/boto/sdb/db/sequence.py
|
| rename to third_party/gsutil/boto/boto/sdb/db/sequence.py
|
| index 5d7dc101126837a84134b584aad93a9b5d47fc79..a01330e854e71c44955375a6d807d85787ce734a 100644
|
| --- a/third_party/gsutil/20110627/boto/boto/sdb/db/sequence.py
|
| +++ b/third_party/gsutil/boto/boto/sdb/db/sequence.py
|
| @@ -136,12 +136,12 @@ class Sequence(object):
|
| self.last_value = None
|
| self.domain_name = domain_name
|
| self.id = id
|
| + if init_val == None:
|
| + init_val = fnc(init_val)
|
| +
|
| if self.id == None:
|
| import uuid
|
| self.id = str(uuid.uuid4())
|
| - if init_val == None:
|
| - init_val = fnc(init_val)
|
| - self.val = init_val
|
|
|
| self.item_type = type(fnc(None))
|
| self.timestamp = None
|
| @@ -151,6 +151,10 @@ class Sequence(object):
|
| fnc = find_class(fnc)
|
| self.fnc = fnc
|
|
|
| + # Bootstrap the value last
|
| + if not self.val:
|
| + self.val = init_val
|
| +
|
| def set(self, val):
|
| """Set the value"""
|
| import time
|
| @@ -175,12 +179,13 @@ class Sequence(object):
|
| def get(self):
|
| """Get the value"""
|
| val = self.db.get_attributes(self.id, consistent_read=True)
|
| - if val and val.has_key('timestamp'):
|
| - self.timestamp = val['timestamp']
|
| - if val and val.has_key('current_value'):
|
| - self._value = self.item_type(val['current_value'])
|
| - if val.has_key("last_value") and val['last_value'] != None:
|
| - self.last_value = self.item_type(val['last_value'])
|
| + if val:
|
| + if val.has_key('timestamp'):
|
| + self.timestamp = val['timestamp']
|
| + if val.has_key('current_value'):
|
| + self._value = self.item_type(val['current_value'])
|
| + if val.has_key("last_value") and val['last_value'] != None:
|
| + self.last_value = self.item_type(val['last_value'])
|
| return self._value
|
|
|
| val = property(get, set)
|
| @@ -197,9 +202,9 @@ class Sequence(object):
|
| def _connect(self):
|
| """Connect to our domain"""
|
| if not self._db:
|
| + import boto
|
| + sdb = boto.connect_sdb()
|
| if not self.domain_name:
|
| - import boto
|
| - sdb = boto.connect_sdb()
|
| self.domain_name = boto.config.get("DB", "sequence_db", boto.config.get("DB", "db_name", "default"))
|
| try:
|
| self._db = sdb.get_domain(self.domain_name)
|
|
|