def construct_url(self, randomstring): """Return URL used in registered_nodify_template to allow user to change password """ # domain as seen by Plone backend frontend_domain = self.portal_state().navigation_root_url() if IAPIRequest.providedBy(self.request): # the reset was requested through restapi, the frontend might have # a different domain. Use volto.frontend_domain in the registry # without triggering possible "record not found" # Default value for volto.frontend_domain is http://localhost:3000 # to consider: maybe we should/could override # @@portal_state/navigation_root_url() for IAPIRequest to fix this on # a higher level registry = getUtility(IRegistry) settings = registry.forInterface(IVoltoSettings, prefix="volto", check=False) frontend_domain = getattr(settings, "frontend_domain", frontend_domain) if frontend_domain.endswith('/'): frontend_domain = frontend_domain[:-1] return "%s/passwordreset/%s" % (frontend_domain, randomstring)
def __before_publishing_traverse__(self, arg1, arg2=None): """Pre-traversal hook that stops traversal to prevent the default view to be appended. Appending the default view would break REST calls. """ # XXX hack around a bug(?) in BeforeTraverse.MultiHook REQUEST = arg2 or arg1 if IAPIRequest.providedBy(REQUEST): return return self._old___before_publishing_traverse__(arg1, arg2)
def publishTraverse(self, request, name): if IAPIRequest.providedBy(request): rest_traverser = RESTTraverse(self.context, self.request) result = rest_traverser.publishTraverse(request, name) else: result = super(MinisiteTraverser, self).publishTraverse(request, name) if IContentish.providedBy(result): path = '/'.join(result.getPhysicalPath()) logger.debug('Traversing {0}'.format(path)) config = queryUtility(IMinisiteConfig, name=path) decorateRequest(request, config) checkPortlet(request, config) return result
def mark_vary_accept(event): """ TODO: pull request for plone.rest """ request = event.request if IAPIRequest.providedBy(request): request.response.appendHeader('Vary', 'Accept')