Exemplo n.º 1
0
 def save(self):
     new = self.new
     ActiveRecord.save(self)
     # update the path
     if new:
         self.created = time.time()
         if self.parent:
             parentNode = Node(self.db)
             parentNode.id = self.parent
             parentNode.load(True)
             self.path = '%s%s/' % (parentNode.path, self.id)
         else:
             self.path = '/%s/' % self.id
         ActiveRecord.save(self)
Exemplo n.º 2
0
    def delete(self):
        """
        Decrease the ref count with 1.
        @return int Returns the current ref count. If it is below 1 than
                    the physical file has to be removed also
        """
        try:
            self.getPrimaryKey()
        except ValueError:
            raise ValueError(
                'The id key must be set in order to delete Meta record')

        self.ref_count = self.ref_count - 1
        if self.ref_count < 1:
            ActiveRecord.delete(self)
        else:
            ActiveRecord.save(self)

        return self.ref_count
Exemplo n.º 3
0
 def save(self):
     if self.new:
         self.ref_count = 0
     self.ref_count += 1
     ActiveRecord.save(self)