nti.webhooks.zcml

Support for configuring webhook delivery using ZCML.

interface nti.webhooks.zcml.IDialectDirective[source]

Create a new dialect subclass of DefaultWebhookDialect and register it as a utility named name.

name

Name

Name of the dialect registration. Limited to ASCII characters.

Implementation:zope.schema.TextLine
Read Only:False
Required:True
Default Value:None
Allowed Type:str
externalizer_name

The name of the externalization adapters to use

Remember, if adapters by this name do not exist, the default will be used.

Implementation:zope.schema.TextLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
externalizer_policy_name

The name of the externalizer policy component to use.

Important

An empty string selects the nti.externalization default policy, which uses Unix timestamps. To use the default policy of nti.webhooks, omit this argument.

Implementation:zope.schema.TextLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
http_method

The HTTP method to use.

This should be a valid method name, but that’s not enforced

Implementation:zope.schema.TextLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
user_agent

The User-Agent header string to use.

Implementation:zope.schema.TextLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
interface nti.webhooks.zcml.IStaticPersistentSubscriptionDirective[source]

Extends: nti.webhooks.zcml.IStaticSubscriptionDirective

Define a local, static, persistent subscription.

Local persistent subscriptions live in the ZODB database, beneath some zope.site.interfaces.ILocalSiteManager.

They are identified by a traversable path beginning from the root of the database; note that this may not be the exact same as a path exposed in the application because this path will need to include the name of the root application object, while application paths typically do not.

This package uses zope.generations to keep track of registered subscriptions and synchronize the database with what is in executed ZCML. Thus it is very important not to remove ZCML directives, or only execute part of the ZCML configuration unless you intend for the subscriptions not found in ZCML to be removed.

All the options are the same as for IStaticSubscriptionDirective, with the addition of the required site_path.

site_path

The path to traverse to the site

A persistent subscription manager will be installed in this site.

Implementation:nti.webhooks.zcml.Path
Read Only:False
Required:True
Default Value:None
Allowed Type:str
interface nti.webhooks.zcml.IStaticSubscriptionDirective[source]

Define a global, static, transient subscription.

Static subscriptions are not persistent and live only in the memory of individual processes. Thus, failed deliveries cannot be re-attempted after process shutdown. And of course the delivery history is also transient and local to a process.

for_

The type of object to attempt delivery for.

When object events of type when are fired for instances providing this interface, webhook delivery to target might be attempted.

The default is objects that implement IWebhookPayload.

This is interpreted as for zope.component.registerAdapter() and may name an interface or a type.

Implementation:zope.configuration.fields.GlobalObject
Read Only:False
Required:False
Default Value:<InterfaceClass nti.webhooks.interfaces.IWebhookPayload>
when

The type of event that should result in attempted deliveries.

A type of IObjectEvent, usually one defined in zope.lifecycleevent.interfaces such as IObjectCreatedEvent. The object field of this event must provide the for_ interface; it’s the data from the object field of this event that will be sent to the webhook.

If not specified, all object events involving the for_ interface will be sent.

This must be an interface.

Implementation:nti.webhooks._schema.ObjectEventInterface
Read Only:False
Required:False
Default Value:<InterfaceClass zope.interface.interfaces.IObjectEvent>

Value Type

Implementation:nti.webhooks._schema.ObjectEventField
Read Only:False
Required:True
Default Value:None
to

The complete destination URL to which the data should be sent

This is an arbitrary HTTPS URL. Only HTTPS is supported for delivery of webhooks.

Implementation:nti.webhooks._schema.HTTPSURL
Read Only:False
Required:True
Default Value:None
Allowed Type:str
dialect

The ID of the IWebhookDialect to use

Dialects are named utilities. They control the authentication, headers, and HTTP method.

Implementation:zope.schema.TextLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
owner

The ID of the IPrincipal that owns this subscription.

This will be validated at runtime when an event arrives. If the current zope.security.interfaces.IAuthentication utility cannot find a principal with the given ID, the delivery will be failed.

Leave unset to disable security checks.

This cannot be changed after creation.

Implementation:nti.webhooks._schema.PermissivePrincipalId
Read Only:False
Required:False
Default Value:None
Allowed Type:str
permission

The permission to check

If given, and an owner is also specified, then only data that has this permission for the owner will result in an attempted delivery. If not given, but an owner is given, this will default to the standard view permission ID, zope.View.

Implementation:zope.security.zcml.Permission
Read Only:False
Required:False
Default Value:None
Allowed Type:str
class nti.webhooks.zcml.Path(*args, **kw)[source]

Bases: zope.schema._bootstrapfields.Text

Accepts a single absolute traversable path.

Unlike zope.configuration.fields.Path, this version requires that the path be absolute and uses URL separators.

fromUnicode(value)[source]
>>> from zope.schema.interfaces import WrongType
>>> from zope.schema.interfaces import ConstraintNotSatisfied
>>> from zope.schema import Text
>>> from zope.schema._compat import text_type
>>> t = Text(constraint=lambda v: 'x' in v)
>>> t.fromUnicode(b"foo x spam") # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
zope.schema._bootstrapinterfaces.WrongType: ('foo x spam', <type 'unicode'>, '')
>>> result = t.fromUnicode(u"foo x spam")
>>> isinstance(result, bytes)
False
>>> str(result)
'foo x spam'
>>> t.fromUnicode(u"foo spam") # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: (u'foo spam', '')