Example #1
0
    def __set__(self, dbobj, value):
        # make sure value is a sequence.
        try:
            value = list(value)
        except TypeError:
            raise ValueError("You must assing a sequence of %s to this dbproperty!" % repr(self.child_class))

        # delete all links from the link_relation that point to the dbobj
        command = sql.delete(
            self.link_relation, sql.where(self.parent_link_column(dbobj), " = ", dbobj.__primary_key__.sql_literal())
        )
        dbobj.__ds__().execute(command)

        # use the result class to (re-)insert the links
        result = self.result(dbobj, self)

        result.append(*value)
Example #2
0
        def unlink_by_primary_key(self, pkey):
            """
            Remove an entry from the link relation that links the parent
            dbobj to a child identfyed by pkey

            @param pkey: An sql.literal instance
            """
            if not isinstance(pkey, sql.literal):
                raise TypeError("pkey must be an sql.literal instance!")

            cmd = sql.delete(
                self.relationship.link_relation,
                sql.where(self.relationship.parent_link_column(self.dbobj),
                          " = ",
                          self.dbobj.__primary_key__.sql_literal(), " AND ",
                          self.relationship.child_link_column(), " = ", pkey))

            self.ds().execute(cmd)
Example #3
0
    def __set__(self, dbobj, value):
        # make sure value is a sequence.
        try:
            value = list(value)
        except TypeError:
            raise ValueError(
                "You must assing a sequence of %s to this dbproperty!" %
                repr(self.child_class))

        # delete all links from the link_relation that point to the dbobj
        command = sql.delete(
            self.link_relation,
            sql.where(self.parent_link_column(dbobj), " = ",
                      dbobj.__primary_key__.sql_literal()))
        dbobj.__ds__().execute(command)

        # use the result class to (re-)insert the links
        result = self.result(dbobj, self)

        result.append(*value)
Example #4
0
        def unlink_by_primary_key(self, pkey):
            """
            Remove an entry from the link relation that links the parent
            dbobj to a child identfyed by pkey

            @param pkey: An sql.literal instance
            """
            if not isinstance(pkey, sql.literal):
                raise TypeError("pkey must be an sql.literal instance!")

            cmd = sql.delete(
                self.relationship.link_relation,
                sql.where(
                    self.relationship.parent_link_column(self.dbobj),
                    " = ",
                    self.dbobj.__primary_key__.sql_literal(),
                    " AND ",
                    self.relationship.child_link_column(),
                    " = ",
                    pkey,
                ),
            )

            self.ds().execute(cmd)
Example #5
0
 def delete_by_primary_key(self, dbclass, primary_key_value):
     where = self.primary_key_where(dbclass, primary_key_value)
     command = sql.delete(dbclass.__relation__, where)
     self.execute(command, True)
Example #6
0
 def __delete__(self):
     cmd = sql.delete(self.__relation__, self.__primary_key__.where())
     self.__ds__().execute(cmd, modify=True)
Example #7
0
 def __delete__(self):
     cmd = sql.delete(self.__relation__,
                      self.__primary_key__.where())
     self.__ds__().execute(cmd, modify=True)
Example #8
0
 def delete_by_primary_key(self, dbclass, primary_key_value):
     where = self.primary_key_where(dbclass, primary_key_value)
     command = sql.delete(dbclass.__relation__, where)
     self.execute(command, True)