Return Etag and Last-Modified values defaults to now for both.
511685
def _conditions(self, full_path, environ):
        """"""
        magic = self._match_magic(full_path)
        if magic is not None:
            return magic.conditions(full_path, environ)
        else:
            mtime = stat(full_path).st_mtime
            return str(mtime), rfc822.formatdate(mtime)
772525
def check_if_modified_since(self, dt, etag=None):
        """"""
        dt = dt.replace(microsecond=0)
        if request.if_modified_since and dt <= request.if_modified_since:
            raise SameContentException(etag, last_modified=dt)
484795
def last_modified(self):
        """"""
        # FIXME: Make this sensible
        last_modified = time.strftime(
            "%a, %d %b %Y %H:%M:%S GMT",
            time.gmtime(time.time()))
        return last_modified
1145949
def last(self, db=_DefaultDB):
        '''
        
        '''
        self._acqXactForReading()
        try:
            with self.xact.cursor(db=db.db) as curs:
                if not curs.last():
                    return None
                return curs.key(), curs.value()
        finally:
            self._relXactForReading()
761002
def lastmod(self, tag):
        """"""
        lastitems = EntryModel.objects.published().order_by('-modification_date').filter(tags=tag).only('modification_date')
        return lastitems[0].modification_date
302313
def _update_defaults(self, defaults, old_version, verbose=False):
        """"""
        old_defaults = self._load_old_defaults(old_version)
        for section, options in defaults:
            for option in options:
                new_value = options[ option ]
                try:
                    old_value = old_defaults.get(section, option)
                except (cp.NoSectionError, cp.NoOptionError):
                    old_value = None
                if old_value is None or \
                  to_text_string(new_value) != old_value:
                    self._set(section, option, new_value, verbose)
1269600
def last_updated(self):
        '''
        '''

        key = self.get_key_from_request()
        max_age = self.get_max_age()

        if max_age == 0:
            return datetime.fromtimestamp(Storage.start_time)

        ttl = self.get_storage().ttl(key)

        if ttl >= 0:
            return datetime.now() - timedelta(
                seconds=(
                    max_age - ttl
                )
            )

        if ttl == -1:
            # Per Redis docs: -1 is no expiry, -2 is does not exists.
            return datetime.fromtimestamp(Storage.start_time)

        # Should never reach here. It means the storage put failed or the item
        # somehow does not exists anymore.
        return datetime.now()
283478
def last_modified_date(filename):
    """"""
    mtime = os.path.getmtime(filename)
    dt = datetime.datetime.utcfromtimestamp(mtime)
    return dt.replace(tzinfo=pytz.utc)
957410
def get_default_values(self):
        """"""
        if not self.process_default_values:
            # Old, pre-Optik 1.5 behaviour.
            return optparse.Values(self.defaults)

        # Load the configuration, or error out in case of an error
        try:
            self.config.load()
        except ConfigurationError as err:
            self.exit(UNKNOWN_ERROR, str(err))

        defaults = self._update_defaults(self.defaults.copy())  # ours
        for option in self._get_all_options():
            default = defaults.get(option.dest)
            if isinstance(default, string_types):
                opt_str = option.get_opt_string()
                defaults[option.dest] = option.check_value(opt_str, default)
        return optparse.Values(defaults)
457133
def if_modified_since(self) -> Optional[datetime.datetime]:
        
        return self._http_date(self.headers.get(hdrs.IF_MODIFIED_SINCE))
647030
def current_timestamp(self) -> datetime:
        """"""
        timestamp = DB.get_hash_value(self._key, 'current_timestamp')
        return datetime_from_isoformat(timestamp)
436080
def defaults(self):
        """"""
        return dict(
            access_right='open',
            description=self.description,
            license='other-open',
            publication_date=self.release['published_at'][:10],
            related_identifiers=list(self.related_identifiers),
            version=self.version,
            title=self.title,
            upload_type='software',
        )
622164
def get_old_value(self, args, kwargs, default=None):
        # type: (List[Any], Dict[str, Any], Any) -> Any
        
        if self.arg_pos is not None and len(args) > self.arg_pos:
            return args[self.arg_pos]
        else:
            return kwargs.get(self.name, default)
140085
protected function buildResponse($etag = null, DateTime $lastModified = null)
    {
        $request = $this->getRequest();
        $response = new Response();
        if ($this->getParameter('content.view_cache') === true) {
            $response->setPublic();
            if ($etag !== null) {
                $response->setEtag($etag);
            }

            if ($this->getParameter('content.ttl_cache') === true) {
                $response->setSharedMaxAge(
                    $this->getParameter('content.default_ttl')
                );
            }

            // Make the response vary against X-User-Hash header ensures that an HTTP
            // reverse proxy caches the different possible variations of the
            // response as it can depend on user role for instance.
            if ($request->headers->has('X-User-Hash')) {
                $response->setVary('X-User-Hash');
            }

            if ($lastModified != null) {
                $response->setLastModified($lastModified);
            }
        }

        return $response;
    }
990451
def get(self):
        
        with self._lock:
            now = datetime.now()
            active = []
            for i, vef in enumerate(self.futures):
                # has expired
                if (vef[1] or datetime.max) <= now:
                    self.futures.pop(i)
                    continue
                # in future
                elif (vef[2] or datetime.min) >= now:
                    continue
                else:
                    active.append(i)

            if active:
                # this will evict values old values
                # because new ones are "more recent" via future
                value, _e, _f = self.futures[active[-1]]
                for i in active[:-1]:
                    self.futures.pop(i)
                return value

            raise ValueError("dicttime: no current value, however future has (%d) values" % len(self.futures))
375964
def get_timestamps(cols, created_name, updated_name):
  """"""
  has_created = created_name in cols
  has_updated = updated_name in cols
  return (created_name if has_created else None, updated_name if has_updated else None)
159019
public static boolean isNotModified(Context context, long lastModified, String etag) {
        // First check etag. Important, if there is an If-None-Match header, we MUST not check the
        // If-Modified-Since header, regardless of whether If-None-Match matches or not. This is in
        // accordance with section 14.26 of RFC2616.

        final String browserEtag = context.header(HeaderNames.IF_NONE_MATCH);
        if (browserEtag != null) {
            // We check the given etag against the given one.
            // If the given one is null, that means that etags are disabled.
            return browserEtag.equals(etag);
        }

        // IF_NONE_MATCH not set, check IF_MODIFIED_SINCE
        final String ifModifiedSince = context.header(HeaderNames.IF_MODIFIED_SINCE);
        if (ifModifiedSince != null && lastModified > 0 && !ifModifiedSince.isEmpty()) {
            try {
                // We do a double check here because the time granularity is important here.
                // If the written date headers are still the same, we are unchanged (the granularity is the
                // second).
                return ifModifiedSince.equals(DateUtil.formatForHttpHeader(lastModified));
            } catch (IllegalArgumentException ex) {
                LoggerFactory.getLogger(CacheUtils.class)
                        .error("Cannot build the date string for {}", lastModified, ex);
                return true;
            }
        }
        return false;
    }