def call(self, action, method, data_obj=None): data = json.dumps(data_obj) if data_obj else '' headers = { 'Authorization': 'Bearer ' + self.config.value['ynab']['accesstoken'], 'Content-type': 'application/json' } log_request(action, method, headers, data_obj) if action == 'GET': reply = requests.get(self.url + method, headers=headers) elif action == 'POST': reply = requests.post(self.url + method, headers=headers, data=data) log_reply(reply) result = reply.json() if "error" in result: raise Exception("{0} (details: {1})".format( result["error"]["name"], result["error"]["detail"])) return result["data"]
def call_requests(self, action, method, data_obj): data = json.dumps(data_obj) if data_obj else '' headers = { 'Cache-Control': 'no-cache', 'User-Agent': 'bunq2ynab', } self.sign(action, method, headers, data) log_request(action, method, headers, data_obj) if action == "GET": reply = requests.get(url + method, headers=headers) elif action == "POST": reply = requests.post(url + method, headers=headers, data=data) elif action == "PUT": reply = requests.put(url + method, headers=headers, data=data) elif action == "DELETE": reply = requests.delete(url + method, headers=headers) log_reply(reply) if reply.headers["Content-Type"] == "application/json": return reply.json() return reply.text
(BLOG_ADMIN_RELATIVE_PATH + 'user/edit/', admin_view.EditUserPage), (BLOG_ADMIN_RELATIVE_PATH + 'user/edit/(\d+)/(\d+)/', admin_view.EditUserByCommentPage), (BLOG_ADMIN_RELATIVE_PATH + 'maintain', admin_view.MaintainPage), (BLOG_ADMIN_RELATIVE_PATH + 'generate_sitemap', admin_view.GenerateSitemapPage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'generate_missing_entities', admin_view.GenerateMissingEntitiesPage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'generate_feed', admin_view.GenerateFeedPage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'flush_cache', admin_view.FlushCachePage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'update_tags_count', admin_view.UpdateTagsCountPage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'update_articles_replies', admin_view.UpdateArticlesRepliesPage, yui.Response), (BLOG_ADMIN_RELATIVE_PATH + 'calendar_token', admin_view.CalendarTokenPage), (BLOG_ADMIN_RELATIVE_PATH + 'subscribe', admin_view.SubscribePage), (BLOG_ADMIN_RELATIVE_PATH + 'remove_old_subscribers', admin_view.RemoveOldSubscribersPage), (BLOG_ADMIN_RELATIVE_PATH + 'scheduled_backup', admin_view.ScheduledBackupPage), (BLOG_ADMIN_RELATIVE_PATH + 'export', admin_view.ExportPage), (BLOG_ADMIN_RELATIVE_PATH + 'import', admin_view.ImportPage), (BLOG_ADMIN_RELATIVE_PATH + 'twitter/status', admin_view.TwitterStatusPage), (BLOG_ADMIN_RELATIVE_PATH + 'twitter/oauth', admin_view.TwitterOauthPage), (BLOG_ADMIN_RELATIVE_PATH + 'twitter/callback', admin_view.TwitterCallbackPage), (BLOG_ADMIN_RELATIVE_PATH + 'xml_rpc', admin_view.XmlRpcPage), (r'/_ah/mail/.+', admin_view.AddArticleByEmail) ], quote_path=False) application = common.log_request(application) def main(): util.run_wsgi_app(application) if __name__ == '__main__': main()
# (r'/bbs/rss\.php', view.RedirectToFeedPage, yui.Response), # ('/bbs/wap/?', view.RedirectToWapHomePage, yui.Response), # ('/bbs', view.RedirectToHomePage, yui.Response), # ('/bbs/.*', view.RedirectToHomePage, yui.Response), ("/login|/logout", view.LoginoutPage, yui.Response), (BLOG_HOME_RELATIVE_PATH + "hub/callback", view.VerifySubscription, yui.Response), (".*", view.NotFoundPage), ] # , yui.Response , quote_path=False, ) if IS_PRODUCTION_SERVER: if ONLY_USE_MAJOR_DOMAIN: application = yui.redirect_to_major_domain(application, MAJOR_DOMAIN) if FEED_DOMAIN: feed_application = yui.WsgiApplication([("/", view.FeedPage, yui.Response), ("/comment", view.CommentFeedPage)]) application = yui.multi_domain_mapping((FEED_DOMAIN, feed_application), ("*", application)) application = common.log_request(hook.hook_app(application)) def main(): util.run_wsgi_app(application) if __name__ == "__main__": main()