+
+ def sync(self):
+ from sfa.storage.alchemy import dbsession
+
+ constraints = [SliverAllocation.sliver_id==self.sliver_id,
+ SliverAllocation.client_id==self.client_id,
+ SliverAllocation.allocation_state==self.allocation_state]
+ results = dbsession.query(SliverAllocation).filter(and_(*constraints))
+ records = []
+ for result in results:
+ records.append(result)
+
+ if not records:
+ dbsession.add(self)
+ else:
+ record = records[0]
+ record.sliver_id = self.sliver_id
+ record.client_id = self.client_id
+ record.allocation_state = self.allocation_state
+ dbsession.commit()
+