def df(fn): opt = __options(fn) required = Options() required.user = name auth = ('pam', required) opt.security.append(auth) return fn
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
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)
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)
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
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)
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)
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)
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
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
def valid(self): if not isinstance(self.opts, dict): raise BadRequest('"options" must be <dict>') return Options(self.opts)