FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
358 stars 73 forks source link

Cannot add momoko #151

Closed mrios01 closed 6 years ago

mrios01 commented 7 years ago

Hi, I am trying to add momoko service to an already running app,but i have no clue of how to. I have run the momoko examples and they work fine, my app has the following structure:

class Application(tornado.web.Application):

def __init__(self):
    handlers = [
        (r"/", HomeHandler),
        (r"/login", LoginHandler),
        (r"/logout", LogoutHandler),
        (r"/register", RegisterHandler),
        (r"/signup", SignupHandler),
        (r"/vprofile/(?P<profile_name>[a-z0-9_-]{3,16}$)", VideoProfileHandler),
        #(r"/(.*)", ContentHandler)
    ]
    tornado.web.Application.__init__(self, handlers, **config)

def main(): tornado.options.parse_command_line() tornado.locale.load_translations(os.path.join(os.path.dirname(file), "translations")) http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start()

if name == "main": main()

If someone could help I would be very greateful.

haizaar commented 7 years ago

Connect to database before starting to listen. Then use momoko from your request handlers: http://momoko.61924.nl/en/latest/tutorial.html#boilerplate

Hope this helps.

P.S. Use super() instead of specifying anscestor class explicitly.

On 28 Feb 2017 23:50, "plug010" notifications@github.com wrote:

Hi, I am trying to add momoko service to an already running app,but i have no clue of how to. I have run the momoko examples and they work fine, my app has the following structure:

class Application(tornado.web.Application):

def init(self): handlers = [ (r"/", HomeHandler), (r"/login", LoginHandler), (r"/logout", LogoutHandler), (r"/register", RegisterHandler), (r"/signup", SignupHandler), (r"/vprofile/(?P[a-z0-9_-]{3,16}$)", VideoProfileHandler),

(r"/(.*)", ContentHandler)

]
tornado.web.Application.__init__(self, handlers, **config)

def main(): tornado.options.parse_command_line() tornado.locale.load_translations(os.path.join(os.path.dirname(file), "translations")) http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start()

if name == "main": main()

If someone could help I would be very greateful.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FSX/momoko/issues/151, or mute the thread https://github.com/notifications/unsubscribe-auth/AADjWXs2pKqN-FiLZeUzDejaqAS9UEmjks5rhJaGgaJpZM4MO7jX .