コード例 #1
0
ファイル: state.py プロジェクト: ArcTanSusan/ratings
    def modified_event(self, dict_, attr, previous, collection=False):
        if attr.key not in self.committed_state:
            if collection:
                if previous is NEVER_SET:
                    if attr.key in dict_:
                        previous = dict_[attr.key]

                if previous not in (None, NO_VALUE, NEVER_SET):
                    previous = attr.copy(previous)

            self.committed_state[attr.key] = previous

        # the "or not self.modified" is defensive at
        # this point.  The assertion below is expected
        # to be True:
        # assert self._strong_obj is None or self.modified

        if self._strong_obj is None or not self.modified:
            instance_dict = self._instance_dict()
            if instance_dict:
                instance_dict._modified.add(self)

            self._strong_obj = self.obj()
            if self._strong_obj is None:
                raise orm_exc.ObjectDereferencedError(
                        "Can't emit change event for attribute '%s' - "
                        "parent object of type %s has been garbage "
                        "collected."
                        % (
                            self.manager[attr.key],
                            orm_util.state_class_str(self)
                        ))
            self.modified = True
コード例 #2
0
ファイル: state.py プロジェクト: shocktrop89/flaskapp
    def modified_event(self, dict_, attr, previous, collection=False):
        if attr.key not in self.committed_state:
            if collection:
                if previous is NEVER_SET:
                    if attr.key in dict_:
                        previous = dict_[attr.key]

                if previous not in (None, NO_VALUE, NEVER_SET):
                    previous = attr.copy(previous)

            self.committed_state[attr.key] = previous

        # the "or not self.modified" is defensive at
        # this point.  The assertion below is expected
        # to be True:
        # assert self._strong_obj is None or self.modified

        if self._strong_obj is None or not self.modified:
            instance_dict = self._instance_dict()
            if instance_dict:
                instance_dict._modified.add(self)

            self._strong_obj = self.obj()
            if self._strong_obj is None:
                raise orm_exc.ObjectDereferencedError(
                    "Can't emit change event for attribute '%s' - "
                    "parent object of type %s has been garbage "
                    "collected." %
                    (self.manager[attr.key], orm_util.state_class_str(self)))
            self.modified = True
コード例 #3
0
    def register_object(self,
                        state,
                        isdelete=False,
                        listonly=False,
                        cancel_delete=False,
                        operation=None,
                        prop=None):
        if not self.session._contains_state(state):
            if not state.deleted and operation is not None:
                util.warn("Object of type %s not in session, %s operation "
                          "along '%s' will not proceed" %
                          (mapperutil.state_class_str(state), operation, prop))
            return False

        if state not in self.states:
            mapper = state.manager.mapper

            if mapper not in self.mappers:
                mapper._per_mapper_flush_actions(self)

            self.mappers[mapper].add(state)
            self.states[state] = (isdelete, listonly)
        else:
            if not listonly and (isdelete or cancel_delete):
                self.states[state] = (isdelete, False)
        return True
コード例 #4
0
    def _synchronize(self,
                     state,
                     child,
                     associationrow,
                     clearkeys,
                     uowcommit,
                     operation=None):
        if state is None or \
            (not self.post_update and uowcommit.is_deleted(state)):
            return

        if operation is not None and \
            child is not None and \
            not uowcommit.session._contains_state(child):
            util.warn(
                "Object of type %s not in session, %s "
                "operation along '%s' won't proceed" %
                (mapperutil.state_class_str(child), operation, self.prop))
            return

        if clearkeys or child is None:
            sync.clear(state, self.parent, self.prop.synchronize_pairs)
        else:
            self._verify_canload(child)
            sync.populate(child, self.mapper, state, self.parent,
                          self.prop.synchronize_pairs, uowcommit, False)
コード例 #5
0
    def register_object(self,
                        state,
                        isdelete=False,
                        listonly=False,
                        cancel_delete=False,
                        operation=None,
                        prop=None):
        if not self.session._contains_state(state):
            if not state.deleted and operation is not None:
                util.warn("Object of type %s not in session, %s operation "
                          "along '%s' will not proceed" %
                          (mapperutil.state_class_str(state), operation, prop))
            return False

        if state not in self.states:
            mapper = state.manager.mapper

            if mapper not in self.mappers:
                mapper._per_mapper_flush_actions(self)

            self.mappers[mapper].add(state)
            self.states[state] = (isdelete, listonly)
        else:
            if not listonly and (isdelete or cancel_delete):
                self.states[state] = (isdelete, False)
        return True
コード例 #6
0
ファイル: dependency.py プロジェクト: BeegorMif/maraschino
    def _synchronize(self, state, child, associationrow, 
                                            clearkeys, uowcommit, operation):
        if associationrow is None:
            return

        if child is not None and not uowcommit.session._contains_state(child):
            if not child.deleted:
                util.warn(
                    "Object of type %s not in session, %s "
                    "operation along '%s' won't proceed" % 
                    (mapperutil.state_class_str(child), operation, self.prop))
            return False

        self._verify_canload(child)

        sync.populate_dict(state, self.parent, associationrow, 
                                        self.prop.synchronize_pairs)
        sync.populate_dict(child, self.mapper, associationrow,
                                        self.prop.secondary_synchronize_pairs)

        return True
コード例 #7
0
    def _synchronize(self, state, child, associationrow,
                                            clearkeys, uowcommit, operation):
        if associationrow is None:
            return

        if child is not None and not uowcommit.session._contains_state(child):
            if not child.deleted:
                util.warn(
                    "Object of type %s not in session, %s "
                    "operation along '%s' won't proceed" %
                    (mapperutil.state_class_str(child), operation, self.prop))
            return False

        self._verify_canload(child)

        sync.populate_dict(state, self.parent, associationrow,
                                        self.prop.synchronize_pairs)
        sync.populate_dict(child, self.mapper, associationrow,
                                        self.prop.secondary_synchronize_pairs)

        return True
コード例 #8
0
ファイル: state.py プロジェクト: AntonNguyen/easy_api
    def modified_event(self, dict_, attr, should_copy, previous, passive=PASSIVE_OFF):
        if attr.key not in self.committed_state:
            if previous is NEVER_SET:
                if passive:
                    if attr.key in dict_:
                        previous = dict_[attr.key]
                else:
                    previous = attr.get(self, dict_)

            if should_copy and previous not in (None, NO_VALUE, NEVER_SET):
                previous = attr.copy(previous)

            self.committed_state[attr.key] = previous


        # the "or not self.modified" is defensive at 
        # this point.  The assertion below is expected
        # to be True:
        # assert self._strong_obj is None or self.modified

        if self._strong_obj is None or not self.modified:
            instance_dict = self._instance_dict()
            if instance_dict:
                instance_dict._modified.add(self)

            self._strong_obj = self.obj()
            if self._strong_obj is None:
                util.warn(
                        "Can't emit change event for attribute '%s.%s' "
                        "- parent object of type %s has been garbage "
                        "collected." 
                        % (
                            self.class_.__name__, 
                            attr.key, 
                            orm_util.state_class_str(self)
                        ))
            self.modified = True
コード例 #9
0
    def modified_event(self, dict_, attr, should_copy, previous, passive=PASSIVE_OFF):
        if attr.key not in self.committed_state:
            if previous is NEVER_SET:
                if passive:
                    if attr.key in dict_:
                        previous = dict_[attr.key]
                else:
                    previous = attr.get(self, dict_)

            if should_copy and previous not in (None, NO_VALUE, NEVER_SET):
                previous = attr.copy(previous)

            self.committed_state[attr.key] = previous


        # the "or not self.modified" is defensive at 
        # this point.  The assertion below is expected
        # to be True:
        # assert self._strong_obj is None or self.modified

        if self._strong_obj is None or not self.modified:
            instance_dict = self._instance_dict()
            if instance_dict:
                instance_dict._modified.add(self)

            self._strong_obj = self.obj()
            if self._strong_obj is None:
                util.warn(
                        "Can't emit change event for attribute '%s.%s' "
                        "- parent object of type %s has been garbage "
                        "collected." 
                        % (
                            self.class_.__name__, 
                            attr.key, 
                            orm_util.state_class_str(self)
                        ))
            self.modified = True
コード例 #10
0
ファイル: dependency.py プロジェクト: BeegorMif/maraschino
    def _synchronize(self, state, child, associationrow,
                                        clearkeys, uowcommit, operation=None):
        if state is None or \
            (not self.post_update and uowcommit.is_deleted(state)):
            return

        if operation is not None and \
            child is not None and \
            not uowcommit.session._contains_state(child):
            util.warn(
                "Object of type %s not in session, %s "
                "operation along '%s' won't proceed" % 
                (mapperutil.state_class_str(child), operation, self.prop))
            return

        if clearkeys or child is None:
            sync.clear(state, self.parent, self.prop.synchronize_pairs)
        else:
            self._verify_canload(child)
            sync.populate(child, self.mapper, state, 
                            self.parent, 
                            self.prop.synchronize_pairs, 
                            uowcommit,
                            False)