def traverse(self, device_id): if self.request.method == 'PUT': validate_proper_contenttype(self.request) # FIXME: This call somehow blocks # body = self.request.bodyStream.read() # user_data = parse_json(body) response = self.request.response user = self.context.get(device_id) if user is None: user = User(name=str(device_id), device_id=str(device_id)) self.context.add(user) response.setStatus('201') else: user.name = str(device_id) response.setStatus('204') # FIXME: user should not be a hardcoded string like this location = located(self.context, self.context.__parent__, self.context.__name__) return location
def _callFUT(self, obj, *args, **kw): from zope.location.location import located return located(obj, *args, **kw)
def __call__(self, oid): contained = self.get(oid) return located(LocationProxy(contained), self.container, contained.__name__)
def get_account(name): util = getUtility(IAuthenticatorPlugin, "users") account = util.getAccount(name) if account is not None: located(account, grok.getSite(), name) return account