'Register an action which will be executed when
:meth:`pyramid.config.Configurator.commit` is called (or executed
immediately if ``autocommit`` is ``True``).
.. warning:: This method is typically only used by :app:`Pyramid`
framework extension authors, not by :app:`Pyramid` application
developers.
The ``discriminator`` uniquely identifies the action.  It must be
given, but it can be ``None``, to indicate that the action never
conflicts.  It must be a hashable value.
The ``callable`` is a callable object which performs the task
associated with the action when the action is executed.  It is
optional.
``args`` and ``kw`` are tuple and dict objects respectively, which
are passed to ``callable`` when this action is executed.  Both are
optional.
``order`` is a grouping mechanism; an action with a lower order will
be executed before an action with a higher order (has no effect when
autocommit is ``True``).
``introspectables`` is a sequence of :term:`introspectable` objects
(or the empty sequence if no introspectable objects are associated
with this action).  If this configurator\'s ``introspection``
attribute is ``False``, these introspectables will be ignored.
``extra`` provides a facility for inserting extra keys and values
into an action dictionary.'

def action(self, discriminator, callable=None, args=(), kw=None, order=0, introspectables=(), **extra):

    assert hash(discriminator)
    if (kw is None):
        kw = {}
    autocommit = self.autocommit
    action_info = self.action_info
    if (not self.introspection):
        introspectables = ()
    if autocommit:
        self.begin()
        try:
            undefer(discriminator)
            if (callable is not None):
                callable(*args, **kw)
            for introspectable in introspectables:
                introspectable.register(self.introspector, action_info)
        finally:
            self.end()
    else:
        action = extra
        action.update(dict(discriminator=discriminator, callable=callable, args=args, kw=kw, order=order, info=action_info, includepath=self.includepath, introspectables=introspectables))
        self.action_state.action(**action)
