Exemplo n.º 1
0
 def save(self):
     if self.validate: self.validate()
     if self.beforeSave: self.beforeSave()
     
     col = mongo.getCollection(self._col)
             
     self._id = self.cleanup_id(self._id)
     
     logger.debug("Persisting %s: %s" %(self._col, self._id))
     self.create_tm = self.create_tm or getTime()
     self.update_tm =  getTime()
     self.tm = self.tm or time.time()
     
     col.save(self, safe=True)
     
     #logger.debug("Done")
     
     if self.afterSave: self.afterSave()
Exemplo n.º 2
0
    def save(self):
        if self.validate: self.validate()
        if self.beforeSave: self.beforeSave()

        col = mongo.getCollection(self._col)

        self._id = self.cleanup_id(self._id)

        logger.debug("Persisting %s: %s" % (self._col, self._id))
        self.create_tm = self.create_tm or getTime()
        self.update_tm = getTime()
        self.tm = self.tm or time.time()

        col.save(self, safe=True)

        #logger.debug("Done")

        if self.afterSave: self.afterSave()
Exemplo n.º 3
0
 def __init__(self, data=None):
     if(data):
         if(isinstance(data, dict)):
             for d in data: self.__setattr__(d, data[d])
         else:
             raise Exception("Invalid initialization data: %s" %data)
         #self.update(data)
     else:
         self.create_tm = getTime()
         self.tm = time.time()
     #self.id = self._id if self._id else None
     if not self._id: self._id= idtool.generate(self._col)
Exemplo n.º 4
0
 def __init__(self, data=None):
     if (data):
         if (isinstance(data, dict)):
             for d in data:
                 self.__setattr__(d, data[d])
         else:
             raise Exception("Invalid initialization data: %s" % data)
         #self.update(data)
     else:
         self.create_tm = getTime()
         self.tm = time.time()
     #self.id = self._id if self._id else None
     if not self._id: self._id = idtool.generate(self._col)