コード例 #1
0
ファイル: server.py プロジェクト: mr-wrmsr/BlackServerOS
 def notification_dispatcher(obj_id, obj_type, obj_name, deleted,
                             revision):
     if deleted:
         obj_name, obj_type = self.get_deleted_object_name_and_type(
             obj_id)
         notification_center.deleteObject(obj_id)
         update = False
     else:
         is_new_object = revision.split("-")[0] == "1"
         obj = self.get_object(obj_type, obj_id)
         if obj:
             if is_new_object:
                 notification_center.addObject(obj)
                 update = False
             else:
                 notification_center.editObject(obj)
                 update = True
         else:
             update = False
     for var in [
             var for var in [obj_id, obj_type, obj_name] if var is None
     ]:
         var = ""
     notification_center.changeFromInstance(obj_id,
                                            obj_type,
                                            obj_name,
                                            deleted=deleted,
                                            update=update)
コード例 #2
0
 def get_changes():
     if not self.stream:
         return False
     while True:
         try:
             for obj_information in self.stream:
                 action = obj_information.get('action')
                 obj_id = obj_information.get('id')
                 obj_type = obj_information.get('type')
                 obj_name = obj_information.get('name')
                 if action == 'CREATE':
                     obj = self.get_object(obj_type, obj_id)
                     notification_center.addObject(obj)
                 elif action == 'UPDATE':
                     obj = self.get_object(obj_type, obj_id)
                     notification_center.editObject(obj)
                 elif action == 'DELETE':
                     notification_center.deleteObject(obj_id, obj_type)
                 else:
                     raise Exception('Invalid action')
                 notification_center.changeFromInstance(
                     action, obj_id, obj_type, obj_name)
         except server_io_exceptions.ChangesStreamStoppedAbruptly:
             notification_center.WorkspaceProblem()
             return False
         time.sleep(0.5)
コード例 #3
0
ファイル: server.py プロジェクト: infobyte/faraday
 def get_changes():
     if not self.stream:
         return False
     while True:
         try:
             for obj_information in self.stream:
                 action = obj_information.get('action')
                 obj_id = obj_information.get('id')
                 obj_type = obj_information.get('type')
                 obj_name = obj_information.get('name')
                 if action == 'CREATE':
                     obj = self.get_object(obj_type, obj_id)
                     notification_center.addObject(obj)
                 elif action == 'UPDATE':
                     obj = self.get_object(obj_type, obj_id)
                     notification_center.editObject(obj)
                 elif action == 'DELETE':
                     notification_center.deleteObject(obj_id, obj_type)
                 else:
                     raise Exception('Invalid action')
                 notification_center.changeFromInstance(
                         action,
                         obj_id,
                         obj_type,
                         obj_name)
         except server_io_exceptions.ChangesStreamStoppedAbruptly:
             notification_center.WorkspaceProblem()
             return False
         time.sleep(0.5)
コード例 #4
0
 def _save_new_object(self, new_object, command_id):
     res = None
     try:
         res = self.mappers_manager.save(new_object, command_id)
     finally:
         new_object.setID(res)
     if res:
         notifier.addObject(new_object)
     return res
コード例 #5
0
ファイル: controller.py プロジェクト: perplext/faraday
 def _save_new_object(self, new_object, command_id):
     res = None
     try:
         res = self.mappers_manager.save(new_object, command_id)
     finally:
         new_object.setID(res)
     if res:
         notifier.addObject(new_object)
     return res
コード例 #6
0
ファイル: server.py プロジェクト: MrMugiwara/faraday
 def notification_dispatcher(obj_id, obj_type, obj_name, deleted, revision):
     if deleted:
         obj_name, obj_type = self.get_deleted_object_name_and_type(obj_id)
         notification_center.deleteObject(obj_id)
         update = False
     else:
         is_new_object = revision.split("-")[0] == "1"
         obj = self.get_object(obj_type, obj_id)
         if obj:
             if is_new_object:
                 notification_center.addObject(obj)
                 update = False
             else:
                 notification_center.editObject(obj)
                 update = True
         else:
             update = False
     for var in [var for var in [obj_id, obj_type, obj_name] if var is None]:
         var = ""
     notification_center.changeFromInstance(obj_id, obj_type,
                                            obj_name, deleted=deleted,
                                            update=update)
コード例 #7
0
ファイル: controller.py プロジェクト: tsxltjecwb/faraday
 def _save_new_object(self, new_object):
     res = self.mappers_manager.save(new_object)
     if res: notifier.addObject(new_object)
     return res
コード例 #8
0
ファイル: controller.py プロジェクト: Sliim/faraday
 def _save_new_object(self, new_object):
     res = self.mappers_manager.save(new_object)
     if res:
         notifier.addObject(new_object)
     return res