def view(self, id, slug="", format="html"): obj = model.entity.get(id) if not obj: abort(404, _("Sorry, there is no entity with id %r") % id) if format == "html": # validate the slug and redirect to the current url if the slug # changed (e.g. fixed typo) with 301 - moved permanently if slug != entity_slug(obj): url = entity_url(obj) redirect(url, code=301) return self._view_no_redirect(id, format)
def view(self, id, slug="", format="html"): # abort if we have no ObjectId. We don't want to # lookup by name. try: oid = ObjectId(id) except InvalidId: abort(404, _("Sorry, there is no %s with code %r") % (self.model.__name__.lower(), id)) if format == "html": # validate the slug and redirect to the current url if the slug # changed (e.g. fixed typo) with 301 - moved permanently entity = self._get_by_id(oid) if slug != entity_slug(entity): url = entity_url(entity) redirect(url, code=301) return super(EntityController, self).view(id, format)