Exemplo n.º 1
0
 def actions(self, obj):
     # this composite action exists to let you use path with a
     # class and still have the path action discriminator work
     # correctly, which reports a conflict if you use the path
     # action with the same model multiple times.
     model = self.model
     if isinstance(obj, type):
         if model is not None:
             raise dectate.DirectiveError("@path decorates class so cannot "
                                          "have explicit model: %s" % model)
         model = obj
     if model is None:
         raise dectate.DirectiveError(
             "@path does not decorate class and has no explicit model")
     yield PathAction(self.path, model, self.variables, self.converters,
                      self.required, self.get_converters, self.absorb), obj
Exemplo n.º 2
0
    def perform(self, obj, predicate_registry):
        if not self.dispatch.external_predicates:
            raise dectate.DirectiveError(
                "@predicate decorator may only be used with "
                "@reg.dispatch_external_predicates: %s" % self.dispatch)

        predicate_registry.register_predicate(obj, self.dispatch, self.name,
                                              self.default, self.index,
                                              self._before, self._after)