How to use the kotti.events.ObjectEvent function in Kotti

To help you get started, we’ve selected a few Kotti examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kotti / Kotti / kotti / events.py View on Github external
anything.
        :type obj: arbitrary

        :param request: current request
        :type request: :class:`kotti.request.Request`
        """

        self.object = obj
        self.request = request


class ObjectInsert(ObjectEvent):
    """This event is emitted when an object is inserted into the DB."""


class ObjectUpdate(ObjectEvent):
    """This event is emitted when an object in the DB is updated."""


class ObjectDelete(ObjectEvent):
    """This event is emitted when an object is deleted from the DB."""


class ObjectAfterDelete(ObjectEvent):
    """This event is emitted after an object has been deleted from the DB.

    .. deprecated:: 0.9
    """


deprecated(
    "ObjectAfterDelete",
github Kotti / Kotti / kotti / workflow.py View on Github external
import transaction
from pyramid.security import DENY_ALL
from repoze.workflow import get_workflow as base_get_workflow

from kotti import DBSession
from kotti import TRUE_VALUES
from kotti.events import ObjectEvent
from kotti.events import notify
from kotti.resources import Content
from kotti.util import command


class WorkflowTransition(ObjectEvent):
    def __init__(self, obj, info, **kwargs):
        super(WorkflowTransition, self).__init__(obj, **kwargs)
        self.info = info


def get_workflow(context, name="security"):
    return base_get_workflow(context, name, context=context)


def reset_workflow(objs=None, purge_existing=False):
    if objs is None:
        objs = DBSession.query(Content)
    for obj in objs:
        if purge_existing:
            obj.state = None
        workflow = get_workflow(obj)
github Kotti / Kotti / kotti / events.py View on Github external
class ObjectAfterDelete(ObjectEvent):
    """This event is emitted after an object has been deleted from the DB.

    .. deprecated:: 0.9
    """


deprecated(
    "ObjectAfterDelete",
    "The ObjectAfterDelete event is deprecated and will be no longer "
    "available starting with Kotti 0.10.",
)


class UserDeleted(ObjectEvent):
    """This event is emitted when an user object is deleted from the DB."""


class DispatcherDict(OrderedDict):
    # Source: http://stackoverflow.com/a/6190500/562769
    def __init__(self, *a, **kw):
        OrderedDict.__init__(self, *a, **kw)
        self.default_factory = list

    def __getitem__(self, key):
        try:
            return OrderedDict.__getitem__(self, key)
        except KeyError:
            return self.__missing__(key)

    def __missing__(self, key):
github Kotti / Kotti / kotti / views / slots.py View on Github external
if not event:
        raise KeyError("Unknown slot '{0}'".format(slot))
    objectevent_listeners[(event[0], None)].append(
        lambda ev: _render_view_on_slot_event(view_name, ev, params)
    )


class RenderLeftSlot(ObjectEvent):
    name = "left"


class RenderRightSlot(ObjectEvent):
    name = "right"


class RenderAboveContent(ObjectEvent):
    name = "abovecontent"


class RenderBelowContent(ObjectEvent):
    name = "belowcontent"


class RenderInHead(ObjectEvent):
    name = "inhead"


class RenderBeforeBodyEnd(ObjectEvent):
    name = "beforebodyend"


class RenderEditInHead(ObjectEvent):
github Kotti / Kotti / kotti / views / slots.py View on Github external
:type params: dict
    """

    event = [e for e in slot_events if e.name == slot]
    if not event:
        raise KeyError("Unknown slot '{0}'".format(slot))
    objectevent_listeners[(event[0], None)].append(
        lambda ev: _render_view_on_slot_event(view_name, ev, params)
    )


class RenderLeftSlot(ObjectEvent):
    name = "left"


class RenderRightSlot(ObjectEvent):
    name = "right"


class RenderAboveContent(ObjectEvent):
    name = "abovecontent"


class RenderBelowContent(ObjectEvent):
    name = "belowcontent"


class RenderInHead(ObjectEvent):
    name = "inhead"


class RenderBeforeBodyEnd(ObjectEvent):
github Kotti / Kotti / kotti / events.py View on Github external
:param obj: The (content) object related to the event.  This is an
                       instance of :class:`kotti.resources.Node` or one its
                       descendants for content related events, but it can be
                       anything.
        :type obj: arbitrary

        :param request: current request
        :type request: :class:`kotti.request.Request`
        """

        self.object = obj
        self.request = request


class ObjectInsert(ObjectEvent):
    """This event is emitted when an object is inserted into the DB."""


class ObjectUpdate(ObjectEvent):
    """This event is emitted when an object in the DB is updated."""


class ObjectDelete(ObjectEvent):
    """This event is emitted when an object is deleted from the DB."""


class ObjectAfterDelete(ObjectEvent):
    """This event is emitted after an object has been deleted from the DB.

    .. deprecated:: 0.9
    """
github Kotti / Kotti / kotti / events.py View on Github external
def clear():
    listeners.clear()
    objectevent_listeners.clear()
    listeners[ObjectEvent].append(objectevent_listeners)
github Kotti / Kotti / kotti / views / slots.py View on Github external
)


class RenderLeftSlot(ObjectEvent):
    name = "left"


class RenderRightSlot(ObjectEvent):
    name = "right"


class RenderAboveContent(ObjectEvent):
    name = "abovecontent"


class RenderBelowContent(ObjectEvent):
    name = "belowcontent"


class RenderInHead(ObjectEvent):
    name = "inhead"


class RenderBeforeBodyEnd(ObjectEvent):
    name = "beforebodyend"


class RenderEditInHead(ObjectEvent):
    name = "edit_inhead"


slot_events = [
github Kotti / Kotti / kotti / events.py View on Github external
:type request: :class:`kotti.request.Request`
        """

        self.object = obj
        self.request = request


class ObjectInsert(ObjectEvent):
    """This event is emitted when an object is inserted into the DB."""


class ObjectUpdate(ObjectEvent):
    """This event is emitted when an object in the DB is updated."""


class ObjectDelete(ObjectEvent):
    """This event is emitted when an object is deleted from the DB."""


class ObjectAfterDelete(ObjectEvent):
    """This event is emitted after an object has been deleted from the DB.

    .. deprecated:: 0.9
    """


deprecated(
    "ObjectAfterDelete",
    "The ObjectAfterDelete event is deprecated and will be no longer "
    "available starting with Kotti 0.10.",
)
github Kotti / Kotti / kotti / views / slots.py View on Github external
name = "right"


class RenderAboveContent(ObjectEvent):
    name = "abovecontent"


class RenderBelowContent(ObjectEvent):
    name = "belowcontent"


class RenderInHead(ObjectEvent):
    name = "inhead"


class RenderBeforeBodyEnd(ObjectEvent):
    name = "beforebodyend"


class RenderEditInHead(ObjectEvent):
    name = "edit_inhead"


slot_events = [
    RenderLeftSlot,
    RenderRightSlot,
    RenderAboveContent,
    RenderBelowContent,
    RenderInHead,
    RenderBeforeBodyEnd,
    RenderEditInHead,
]