Esempio n. 1
0
 def df(fn):
     opt = __options(fn)
     required = Options()
     required.user = name
     auth = ('pam', required) 
     opt.security.append(auth)
     return fn
Esempio n. 2
0
 def df(fn):
     opt = __options(fn)
     opt.shared = shared
     if secret:
         required = Options()
         required.secret = secret
         auth = ('secret', required)
         opt.security.append(auth)
     Remote.add(fn)
     return fn
Esempio n. 3
0
 def process(self, jnl, path):
     log.info(path)
     try:
         je = jnl.read(path)
         je = Options(je)
         notify = Options(je.notify)
         system = System(notify.systemid)
         r = system.notify(notify.method, notify.path, je.body)
         jnl.delete(path)
     except Exception:
         log.exception(path)
Esempio n. 4
0
 def call(self, classname, method, request, replyto, any):
     options = Options(self.options)
     if replyto:
         options.ctag = ReplyManager.CTAG
         options.watchdog = Services.watchdog
         options.any = dict(any=any, replyto=replyto)
     agent = proxy.agent(self.uuid, **options)
     Class = agent[classname]
     inst = Class()
     cntr = request.cntr
     if cntr:
         inst(*cntr[0], **cntr[1])
     fn = inst[method]
     return fn(*request.args, **request.kwargs)
Esempio n. 5
0
 def call(self, classname, method, request, replyto, any):
     options = Options(self.options)
     if replyto:
         options.ctag = ReplyManager.CTAG
         options.watchdog = Services.watchdog
         options.any = dict(any=any, replyto=replyto)
     agent = proxy.agent(self.uuid, **options)
     Class = agent[classname]
     inst = Class()
     cntr = request.cntr
     if cntr:
         inst(*cntr[0], **cntr[1])
     fn = inst[method]
     return fn(*request.args, **request.kwargs)        
Esempio n. 6
0
def __options(fn):
    """
    Ensure funtion has the gofer options attribute
    and return it.
    @param fn: A function
    @return: The funtion options object.
    @rtype: L{Options}
    """
    if not hasattr(fn, NAME):
        opt = Options()
        opt.security = []
        setattr(fn, NAME, opt)
    else:
        opt = getattr(fn, NAME)
    return opt
Esempio n. 7
0
 def body(self):
     body = Controller.body(self)
     if body is None:
         body = {}
     if not isinstance(body, dict):
         raise BadRequest('"body" must be <dict>')
     return Options(body)
Esempio n. 8
0
 def failed(self, reply):
     log.info('failed: %s', reply)
     any = Options(reply.any)
     body = dict(sn=reply.sn,
                 any=any.any,
                 status=status(reply.exval),
                 exception=exdict(reply.exval, reply),
                 reply=None)
     nj = NotifyJournal()
     nj.write(reply.sn, any.replyto, body)
Esempio n. 9
0
 def succeeded(self, reply):
     log.info('succeeded: %s', reply)
     any = Options(reply.any)
     body = dict(sn=reply.sn,
                 any=any.any,
                 status=(200, HTTP_CODES[200]),
                 reply=reply.retval,
                 exception=None)
     nj = NotifyJournal()
     nj.write(reply.sn, any.replyto, body)
Esempio n. 10
0
 def valid(self):
     request = self.request
     if not request:
         request = {}
     if not isinstance(request, dict):
         raise BadRequest('"request" must be <dict>')
     request = Options(request)
     self.cntr(request)
     self.args(request)
     self.kwargs(request)
     return request
Esempio n. 11
0
 def valid(self):
     replyto = self.replyto
     if replyto is None:
         return
     if not isinstance(replyto, dict):
         raise BadRequest('"replyto" must be <dict>')
     replyto = Options(replyto)
     self.method(replyto)
     self.path(replyto)
     self.systemid(replyto)
     return replyto
Esempio n. 12
0
 def valid(self):
     if not isinstance(self.opts, dict):
         raise BadRequest('"options" must be <dict>')
     return Options(self.opts)