Exemple #1
0
    def report(self):
        # Already approved by moderation - can't be reported
        if self.mod_reports < 0 or self.mod_reports >= self.reports_max-1:
            return

        req = reqfilter.get_request()
        sKey = str(self.key())
        if not req.once_per_user("report.%s" % sKey):
            return
        
        self.mod_reports += 1
Exemple #2
0
    def report(self):
        # Already approved by moderation - can't be reported
        if self.mod_reports < 0 or self.mod_reports >= self.reports_max - 1:
            return

        req = reqfilter.get_request()
        sKey = str(self.key())
        if not req.once_per_user("report.%s" % sKey):
            return

        self.mod_reports += 1
Exemple #3
0
    def deferred_put(self):
        """
        If the model has been marked as dirty, try to write it out.
        """
        if self._cache_state == self.cache_state.clean:
            return

        self.ensure_cached()

        try:
            # Write to storage if critical or dirty AND old
            if self._cache_state == self.cache_state.critical or \
                not self._write_rate.is_exceeded(reqfilter.get_request().secsNow):
                self.put()
        except Exception, e:
            logging.info("Failed to write deferred-write cache: %s (%s)" %
                         (self._model_cache_key(), e.message))
            pass
Exemple #4
0
 def deferred_put(self):
     """
     If the model has been marked as dirty, try to write it out.
     """
     if self._cache_state == self.cache_state.clean:
         return
     
     self.ensure_cached()
     
     try:
         # Write to storage if critical or dirty AND old
         if self._cache_state == self.cache_state.critical or \
             not self._write_rate.is_exceeded(reqfilter.get_request().secsNow):
             self.put()
     except Exception, e:
         logging.info("Failed to write deferred-write cache: %s (%s)" % (
                      self._model_cache_key(),
                      e.message
                      ))
         pass
Exemple #5
0
def hours_from_datetime(dt=None):
    if dt is None:
        dt = reqfilter.get_request().dtNow
    ddt = dt - dtBase
    hrs = ddt.days*hrsDay + float(ddt.seconds)/60/60
    return hrs