def main(): """CGI-style request handler to dump the configuration. Put this in your app.yaml to enable (you can pick any URL): - url: /lib_config script: $PYTHON_LIB/cyclozzo/apps/api/lib_config.py Note: unless you are using the SDK, you must be admin. """ if not os.getenv('SERVER_SOFTWARE', '').startswith('Dev'): from cyclozzo.apps.api import users if not users.is_current_user_admin(): if users.get_current_user() is None: print 'Status: 302' print 'Location:', users.create_login_url( os.getenv('PATH_INFO', '')) else: print 'Status: 403' print print 'Forbidden' return print 'Content-type: text/plain' print _default_registry._dump()
def main(): """CGI-style request handler to dump the configuration. Put this in your app.yaml to enable (you can pick any URL): - url: /lib_config script: $PYTHON_LIB/cyclozzo/apps/api/lib_config.py Note: unless you are using the SDK, you must be admin. """ if not os.getenv('SERVER_SOFTWARE', '').startswith('Dev'): from cyclozzo.apps.api import users if not users.is_current_user_admin(): if users.get_current_user() is None: print 'Status: 302' print 'Location:', users.create_login_url(os.getenv('PATH_INFO', '')) else: print 'Status: 403' print print 'Forbidden' return print 'Content-type: text/plain' print _default_registry._dump()
def get(self): user = users.get_current_user() if user: self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, ' + user.nickname()) else: self.redirect(users.create_login_url(self.request.uri))
def check_login(self, *args): if self.request.method != 'GET': raise webapp.Error('The check_login decorator can only be used for GET ' 'requests') user = users.get_current_user() if not user: self.redirect(users.create_login_url(self.request.uri)) return else: handler_method(self, *args)
def check_login(self, *args): if self.request.method != 'GET': raise webapp.Error( 'The check_login decorator can only be used for GET ' 'requests') user = users.get_current_user() if not user: self.redirect(users.create_login_url(self.request.uri)) return else: handler_method(self, *args)
def get(self): greetings_query = Greeting.all().order('-date') greetings = greetings_query.fetch(10) if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Login' template_values = { 'greetings': greetings, 'url': url, 'url_linktext': url_linktext, } path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values))