API Reference¶
nti.app.pyramid_zope¶
DOCUMENT ME.
nti.app.pyramid_zope.request¶
Partial support for making a Pyramid request/response object pair work more like a Zope request.
Partially based on ideas from pyramid_zope_request
-
class
PyramidZopeRequestProxy(base)[source]¶ Bases:
zope.proxy.decorator.SpecificationDecoratorBaseMakes a Pyramid IRequest object look like a Zope request for purposes of rendering. The existing interfaces (IRequest) are preserved.
Changes to a proxy, including annotations, are persistent, and will be reflected if the same pyramid request is proxied again later (unlike
pyramid_zope_request, which takes the approach of subclassingzope.publisher.base.BaseRequestand overriding certain methods to call through to pyramid, but not things like annotations.)Note
Most of this behaviour is added from reverse-engineering what existing zope code, most notably
z3c.table.tableuses. Some additional support forz3c.formcomes from looking at whatpyramid_zope_requestdoes.-
environment¶ Alias for
environ
-
nti.app.pyramid_zope.traversal¶
Support for resource tree traversal.
-
class
ZopeResourceTreeTraverser(root)[source]¶ Bases:
pyramid.traversal.ResourceTreeTraverserA
pyramid.interfaces.ITraverserbased on pyramid’s default traverser, but modified to use thezope.traversing.apimachinery instead of (only) dictionary lookups. This provides is with the flexibility of thezope.traversing.interfaces.ITraversableadapter pattern, plus the support of namespace lookups (zope.traversing.namespace.nsParse()andzope.traversing.namespace.namespaceLookup()).As this object traverses, it fires
IBeforeTraverseEventevents. If you either load the configuration fromzope.app.publicationor manually enable thezope.site.site.threadSiteSubscriberto subscribe to this event, then any Zope site managers found along the way will be made the current site.
-
class
resource(context, request)[source]¶ Bases:
zope.traversing.namespace.resourceHandles resource lookup in a way compatible with
zope.browserresource. This package registers resources as named adapters fromIDefaultBrowserLayerto Interface. We connect the two by making the pyramid request implement the right thing.
nti.app.pyramid_zope.security¶
Integrations for zope.security and zope.authentication.
Many of these are adapters registered automatically by this package’s configure.zcml.
In plain Zope3, the zope.publisher.interfaces.IRequest is
an zope.security.interfaces.IParticipation for the request’s
principal (or the unauthenticated or fallback unauthenticated
principal). That request is defined to be the first participation in
the interaction by zope.app.publication.zopepublication (right after
authentication and right before traversal).
Pyramid’s request is not a participation, and Pyramid doesn’t establish an interaction either. Something else (typically a tween like TODO: Copy Tween) does that. These adapters will work only after that is done.
-
interaction_from_request(request: IRequest) → IInteraction[source]¶ Find the
IInteractionfor the request.The request is adapted to
IInteractionManagement(using the defaultzope.security.managementfor a thread-local interaction if there is no specific adapter registered), and the current interaction is returned.This is registered as an adapter on the Pyramid
IRequestinterface; to provide a more specific policy, register an adapter on the concrete class.Raises: zope.security.interfaces.NoInteraction – If there is no interaction. See also
zope.security.interfaces.IInteractionManagement
-
principal_from_interaction(interaction: IInteraction) → IPrincipal[source]¶ Find the primary
IPrincipalfor the interaction. The primary principal is the principal of the first participation.
-
principal_from_request(request: IRequest) → IPrincipal[source]¶ Find the primary
IPrincipalfor the request.First adapts the request into an
IInteraction(probably usinginteraction_from_request()), and then adapts the interaction into anIPrincipal(probably usingprincipal_from_interaction()). If there is no interaction, the unauthenticated principal is returned.This is registered as an adapter on the Pyramid
IRequestinterface; to provide a more specific policy, register an adapter on the concrete class.