def read(self, id, format='html'): # Check we know the content type, if not then it is likely a revision # and therefore we should merge the format onto the end of id ctype,extension,loader = self._content_type_for_format(format) if not ctype: # Reconstitute the ID if we don't know what content type to use ctype = "text/html; charset=utf-8" id = "%s.%s" % (id, format) format = 'html' else: format = extension response.headers['Content-Type'] = ctype package_type = self._get_package_type(id.split('@')[0]) context = {'model': model, 'session': model.Session, 'user': c.user or c.author, 'extras_as_string': True, 'for_view': True} data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id, format='html'): if not format == 'html': ctype,extension,loader = self._content_type_from_extension(format) if not ctype: # An unknown format, we'll carry on in case it is a # revision specifier and re-constitute the original id id = "%s.%s" % (id, format) ctype, format, loader = "text/html; charset=utf-8", "html", MarkupTemplate else: ctype,extension,loader = self._content_type_from_accept() response.headers['Content-Type'] = ctype package_type = self._get_package_type(id.split('@')[0]) context = {'model': model, 'session': model.Session, 'user': c.user or c.author, 'extras_as_string': True, 'for_view': True} data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id): package_type = self._get_package_type(id.split('@')[0]) context = { 'model': model, 'session': model.Session, 'user': c.user or c.author, 'extras_as_string': True, 'for_view': True } data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id): context = {'model': model, 'session': model.Session, 'user': c.user or c.author, 'extras_as_string': True, 'schema': self._form_to_db_schema()} data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id, format='html'): if not format == 'html': ctype, extension, loader = \ self._content_type_from_extension(format) if not ctype: # An unknown format, we'll carry on in case it is a # revision specifier and re-constitute the original id id = "%s.%s" % (id, format) ctype, format, loader = "text/html; charset=utf-8", "html", \ MarkupTemplate else: ctype, format, loader = self._content_type_from_accept() response.headers['Content-Type'] = ctype package_type = self._get_package_type(id.split('@')[0]) context = { 'model': model, 'session': model.Session, 'user': c.user or c.author, 'for_view': True, 'auth_user_obj': c.userobj } data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = h.date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id, format='html'): # Check we know the content type, if not then it is likely a revision # and therefore we should merge the format onto the end of id ctype, extension, loader = self._content_type_for_format(format) if not ctype: # Reconstitute the ID if we don't know what content type to use ctype = "text/html; charset=utf-8" id = "%s.%s" % (id, format) format = 'html' else: format = extension response.headers['Content-Type'] = ctype package_type = self._get_package_type(id.split('@')[0]) context = { 'model': model, 'session': model.Session, 'user': c.user or c.author, 'extras_as_string': True, 'for_view': True } data_dict = {'id': id} # interpret @<revision_id> or @<date> suffix split = id.split('@') if len(split) == 2: data_dict['id'], revision_ref = split if model.is_id(revision_ref): context['revision_id'] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context['revision_date'] = date except TypeError, e: abort(400, _('Invalid revision format: %r') % e.args) except ValueError, e: abort(400, _('Invalid revision format: %r') % e.args)
def read(self, id, format="html"): # Check we know the content type, if not then it is likely a revision # and therefore we should merge the format onto the end of id ctype, extension, loader = self._content_type_for_format(format) if not ctype: # Reconstitute the ID if we don't know what content type to use ctype = "text/html; charset=utf-8" id = "%s.%s" % (id, format) format = "html" else: format = extension response.headers["Content-Type"] = ctype package_type = self._get_package_type(id.split("@")[0]) context = { "model": model, "session": model.Session, "user": c.user or c.author, "extras_as_string": True, "for_view": True, } data_dict = {"id": id} # interpret @<revision_id> or @<date> suffix split = id.split("@") if len(split) == 2: data_dict["id"], revision_ref = split if model.is_id(revision_ref): context["revision_id"] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context["revision_date"] = date except TypeError, e: abort(400, _("Invalid revision format: %r") % e.args) except ValueError, e: abort(400, _("Invalid revision format: %r") % e.args)
def read(self, id, format="html"): if not format == "html": ctype, extension, loader = self._content_type_from_extension(format) if not ctype: # An unknown format, we'll carry on in case it is a # revision specifier and re-constitute the original id id = "%s.%s" % (id, format) ctype, format, loader = "text/html; charset=utf-8", "html", MarkupTemplate else: ctype, format, loader = self._content_type_from_accept() response.headers["Content-Type"] = ctype package_type = self._get_package_type(id.split("@")[0]) context = { "model": model, "session": model.Session, "user": c.user or c.author, "extras_as_string": True, "for_view": True, } data_dict = {"id": id} # interpret @<revision_id> or @<date> suffix split = id.split("@") if len(split) == 2: data_dict["id"], revision_ref = split if model.is_id(revision_ref): context["revision_id"] = revision_ref else: try: date = date_str_to_datetime(revision_ref) context["revision_date"] = date except TypeError, e: abort(400, _("Invalid revision format: %r") % e.args) except ValueError, e: abort(400, _("Invalid revision format: %r") % e.args)