Beispiel #1
0
    def _set_attr(self, key, value, default_value=None):
        if value is None:
            value = default_value
        else:
            # make sure inputs match definition
            d = self.get_definition()
            if d and key in d:
                value = Type.coerce_type(value, d[key].get_type())

        self._current_state[key] = value
Beispiel #2
0
    def _set_attr(self, key, value, default_value=None):
        if value is None:
            value = default_value
        else:
            # make sure inputs match definition
            d = self.get_definition()
            if d and key in d:
                value = Type.coerce_type(value, d[key].get_type())

        self._current_state[key] = value
Beispiel #3
0
 def __init__(self,
              *args,
              comment=None,
              parameters=None,
              returns=None,
              optional_keys=None,
              **kargs):
     super().__init__(*args, **kargs)
     self.parameters = parameters or {}
     self.comment = comment
     self.return_data = Type.serialize(returns, optional_keys)
Beispiel #4
0
 def update_rule_with_meta(self, request = None, session_store=None):
     m = self.get_method(request, session_store)
     
     if hasattr(m, "meta"):
         if "comment" in m.meta:
             self.set_comment(m.meta["comment"])
         if "return" in m.meta:
             optional_keys = []
             if "optional_keys" in m.meta:
                 optional_keys = m.meta["optional_keys"]
             self.return_data = Type.serialize(m.meta["return"], optional_keys)
         if "parameters" in m.meta:
             self.set_parameters(m.meta["parameters"])
         if "not_implemented" in m.meta:
             self.not_implemented = True 
         
     return m
Beispiel #5
0
    def update_rule_with_meta(self, request=None, session_store=None):
        m = self.get_method(request, session_store)

        if hasattr(m, "meta"):
            if "comment" in m.meta:
                self.set_comment(m.meta["comment"])
            if "return" in m.meta:
                optional_keys = []
                if "optional_keys" in m.meta:
                    optional_keys = m.meta["optional_keys"]
                self.return_data = Type.serialize(m.meta["return"],
                                                  optional_keys)
            if "parameters" in m.meta:
                self.set_parameters(m.meta["parameters"])
            if "not_implemented" in m.meta:
                self.not_implemented = True

        return m
Beispiel #6
0
 def __init__(self, *args, comment = None, parameters = None, returns = None, optional_keys=None, **kargs):
     super().__init__(*args, **kargs)
     self.parameters = parameters or {}
     self.comment = comment
     self.return_data =  Type.serialize(returns, optional_keys)