当前位置: 首页>>代码示例>>Python>>正文


Python Object.deleted方法代码示例

本文整理汇总了Python中object.Object.deleted方法的典型用法代码示例。如果您正苦于以下问题:Python Object.deleted方法的具体用法?Python Object.deleted怎么用?Python Object.deleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object.Object的用法示例。


在下文中一共展示了Object.deleted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sync_from_client

# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import deleted [as 别名]
 def sync_from_client(self, objects):
     
     result = {}
     for sob in objects:
         
         exists = False
         conflict = False
         
         for o in self.objects:
             if o.guid == sob.guid:
                 exists = True
                 o.value = sob.value
                 o.deleted = sob.deleted
                 self.counter += 1
                 o.lastupdate_counter = self.counter
             elif o.pk == sob.pk:
                 # pk conflict: do nothing because this should not occur on server
                 # client will always sync from server to client first and handle
                 # any pk conflicts before syncing from client to server
                 exists = True
                 conflict = True
                 result['statuscode'] = NOK
         
         if not exists:
             no = Object(pk=sob.pk, name=sob.name, value=sob.value, guid=sob.guid)
             no.deleted = sob.deleted
             self.counter += 1
             no.lastupdate_counter = self.counter
             self.objects.append(no)
     
     if 'statuscode' not in result:
         result['statuscode'] = OK
     result['servercounter']  = self.counter
     return result
开发者ID:donarb,项目名称:appsync-py,代码行数:36,代码来源:server.py

示例2: sync_from_server

# 需要导入模块: from object import Object [as 别名]
# 或者: from object.Object import deleted [as 别名]
 def sync_from_server(self):
     
     result = self.server.sync_to_client(self.lastsync_servercounter)
     
     for sob in result['objects']:
         
         exists = False
         for o in self.objects:
             
             if o.guid == sob.guid or o.pk == sob.pk:
                 
                 exists = True
                 
                 # Handle pk conflict
                 if o.pk == sob.pk:
                     o.guid = sob.guid
                 
                 # Check for conflict (object updated locally since last sync to server)
                 if o.lastupdate_counter > self.lastsync_counter:
                     # Decide how to handle conflict
                     if self.conflict_handling == SERVERPRIORITY:
                         o.value = sob.value
                         o.deleted = sob.deleted
                     elif self.conflict_handling == CLIENTPRIORITY:
                         ''' no change to local object '''
                     elif self.conflict_handling == TIMESTAMPPRIORITY:
                         if sob.timestampupdated > o.timestampupdated:
                             o.value = sob.value
                             o.deleted = sob.deleted
                             o.timestampupdated = datetime.now()
                 else:
                     # No conflict, update object locally
                     o.value = sob.value
                     o.deleted = sob.deleted
         
         if not exists:
             
             no = Object(sob.pk, sob.name, sob.value, sob.guid)
             no.deleted = sob.deleted
             no.lastupdate_counter = self.counter
             self.objects.append(no)
     
     if result['statuscode'] == OK:
         self.lastsync_servercounter = result['servercounter']
开发者ID:donarb,项目名称:appsync-py,代码行数:46,代码来源:client.py


注:本文中的object.Object.deleted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。