Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:29:15+00:00 2026-06-13T14:29:15+00:00

I have an handler in a Python page written following the guide lines of

  • 0

I have an handler in a Python page written following the guide lines of the Tornado web server. I would to bring this handler in an other page, always linked with the main python page of Tornado.

In that way can I create a new page so I can have a nice project and not an unique page of thousand of lines?

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:29:16+00:00Added an answer on June 13, 2026 at 2:29 pm
    class BaseHandler(tornado.web.RequestHandler):
        @tornado.web.removeslash
        def get_current_user(self):
             return self.get_secure_cookie("mechtari")
        @property 
        def db(self):
            if not hasattr(BaseHandler,"_db"):
                _db = pymongo.Connection().essog
                return _db
        @property
        def fs(self):
            if not hasattr(BaseHandler,"_fs"):
                _fs = gridfs.GridFS(self.db)
                return _fs
    

    now all what i’ll do will inherit from this handler:

    class LoginHandler(BaseHandler):
        def post(self):
        # do a database search, so i need to connect to database, so no need to the database everytime and make the connection.
    
    
    class AchatsHandler(BaseHandler):
        @tornado.web.authenticated
        def get(self):
            # render me a page that requires a user to be authentificated, so i always use the base handler
    

    and in the url specs, you only precise the name of classes to bind them to urls.

    urls = [
    (r"/login", handlers.LoginHandler),
    (r"/achats/*", handlers.AchatsHandler),
    ]
    

    and see, there is no BaseHandler in the url dictionnary!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to extract an information from the following web page with Python 3:
I have a simple Python script that uses a signal handler for Ctl-C. If
I have a Handler class that looks like this: class Handler{ public $group; public
I have an event handler set up using plain javascript like this: myElement.addEventListener('drop', handleDrop,
I have a web server that has all of the configurations set in the
I have done everything said on the following page. https://help.ubuntu.com/community/Django but it gives me
I have built little custom web framework on top of Python 3.2 using Cherrypy
So basically, I'm a bit new to Python. I created a server and have
I would like to fill in and submit a form on a web page
I have 4 URLs that I would like to redirect to my main page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.