Beispiel #1
0
    def __call__(self, function):
        frame = sys._getframe(1)
        if not frame_is_module(frame):
            raise GrokImportError("@grok.subscribe can only be used on module "
                                  "level.")

        if not self.subscribed:
            raise GrokImportError("@grok.subscribe requires at least one "
                                  "argument.")

        subscribers = frame.f_locals.get('__grok_subscribers__', None)
        if subscribers is None:
            frame.f_locals['__grok_subscribers__'] = subscribers = []
        subscribers.append((function, self.subscribed))
    def __call__(self, handler):
        frame = sys._getframe(1)
        if not frame_is_module(frame):
            raise GrokImportError(
                '@customize can only be used on module level')
        if not self.options:
            raise GrokImportError(
                '@customize options are missing')

        customizations = frame.f_locals.get(
            '__zeam_form_customizations__', None)
        if customizations is None:
            frame.f_locals['__zeam_form_customizations__'] = customizations = []
        customizations.append((handler, self.options))
        return handler
    def __call__(self, function):
        frame = sys._getframe(1)
        if not frame_is_module(frame):
            raise GrokImportError("@grok.subscribe can only be used on module "
                                  "level.")

        if not self.subscribed:
            raise GrokImportError("@grok.subscribe requires at least one "
                                  "argument.")

        # Add the function and subscribed interfaces to the
        # grok.subscribers module annotation.
        subscribers = frame.f_locals.get('__grok_subscribers__', None)
        if subscribers is None:
            frame.f_locals['__grok_subscribers__'] = subscribers = []
        subscribers.append((function, self.subscribed))

        # Also store the subscribed interfaces on the
        # attribute__component_adapts__ for provideHandler to register
        # the subscriber (in case you don't grok your package and
        # register it manually)
        return zope.component.adapter(*self.subscribed)(function)
Beispiel #4
0
    def __call__(self, function):
        frame = sys._getframe(1)
        if not frame_is_module(frame):
            raise GrokImportError("@grok.subscribe can only be used on module "
                                  "level.")

        if not self.subscribed:
            raise GrokImportError("@grok.subscribe requires at least one "
                                  "argument.")

        # Add the function and subscribed interfaces to the
        # grok.subscribers module annotation.
        subscribers = frame.f_locals.get('__grok_subscribers__', None)
        if subscribers is None:
            frame.f_locals['__grok_subscribers__'] = subscribers = []
        subscribers.append((function, self.subscribed))

        # Also store the subscribed interfaces on the
        # attribute__component_adapts__ for provideHandler to register
        # the subscriber (in case you don't grok your package and
        # register it manually)
        return zope.component.adapter(*self.subscribed)(function)
Beispiel #5
0
 def check(self, frame):
     return util.frame_is_module(frame) or is_fake_module(frame)
Beispiel #6
0
 def check(self, frame):
     return util.frame_is_class(frame) or util.frame_is_module(frame)