def save(self, req): if not req.email: return Response(status=403, content_type='text/plain', body='Not logged in') email, path = self.split_path(req, 'save') if email != req.email: return Response(status=403, content_type='text/plain', body='Email not correct (%r, not %r)' % (req.email, email)) if req.method != 'PUT': return exc.HTTPMethodNotAllowed(allow='PUT') data = req.json filename = self.make_filename('page', email, path) write_file(filename, json.dumps(data)) location = req.application_url + '/page/' + urllib.quote( email) + '/' + urllib.quote(path, '') return Response(json={'location': location})
def save(self, req): if not req.email: return Response( status=403, content_type='text/plain', body='Not logged in') email, path = self.split_path(req, 'save') if email != req.email: return Response( status=403, content_type='text/plain', body='Email not correct (%r, not %r)' % (req.email, email)) if req.method != 'PUT': return exc.HTTPMethodNotAllowed(allow='PUT') data = req.json filename = self.make_filename('page', email, path) write_file(filename, json.dumps(data)) location = req.application_url + '/page/' + urllib.quote(email) + '/' + urllib.quote(path, '') return Response( json={'location': location})
def secret(self): secret = read_file(self._secret_filename) if not secret: secret = make_random(10) write_file(self._secret_filename, secret) return secret