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 7768335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:53:31+00:00 2026-06-01T15:53:31+00:00

I found many examples for older versions of CherryPy but they each referenced importing

  • 0

I found many examples for older versions of CherryPy but they each referenced importing modules not found in cherrypy 3.2.2. Looking in the documentation, I found a reference to the fact that there is built in functionality with storage_type (one of ‘ram’, ‘file’, ‘postgresql’).

  • 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-01T15:53:32+00:00Added an answer on June 1, 2026 at 3:53 pm

    For a start you could take a look at

    https://github.com/3kwa/cherrys

    how this guy writes his own session class and overwrites some methods. He does it for redis not MySQL. You would write methods for MySQL. A very similar class already exists in cherrypy in “cherrpy/lib/sessions.py”:

    class PostgresqlSession(Session)
    

    which is very similar to what you want. I’d say, take the implementing approach from the “3kwa” but instead of his RedisSession-class copy the PostgresqlSession-class from “cherrpy/lib/sessions.py” and alter to match proper MySQL-Syntax.

    A possible path could be:

    Download the “cherrys.py” from above link and rename into “mysqlsession.py”. Overwrite the “RedisSessions(Session)” with the “PostgresqlSession(Session)” from “cherrpy/lib/sessions.py” and rename to “MySQLSession(Session)”. Be sure to add

    locks = {}
    
    def acquire_lock(self):
        """Acquire an exclusive lock on the currently-loaded session data."""
        self.locked = True
        self.locks.setdefault(self.id, threading.RLock()).acquire()
    
    def release_lock(self):
        """Release the lock on the currently-loaded session data."""
        self.locks[self.id].release()
        self.locked = False
    

    to your new “MySQLSession”-class (like it is done in RedisSession(Session). Alter the the PostgreSQL-Syntax to match MySQL-Syntax (that shouldn’t be difficult). Put the “mysqlsession.py” somewhere below your project directory and import in the application with

    import mysqlsession
    

    and use

    cherrypy.lib.sessions.MySQLSession = mysqlsession.MySQLSession
    

    in the initialization of you app. In the config

    tools.sessions.storage_type : 'mysql'
    

    and the parameters (like host, port, etc.) like you would with class “PostgreSQL”.

    I can be wrong all along. But this is how I would try to solve this.

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

Sidebar

Related Questions

I've found many examples on how to search for files that exist in a
I found many css/js menu scripts on various sites they work well is in
I've found many definitions of the 'var' statement but most of them are incomplete
I have found many people with simliar issues but no soultions...basically I have two
I have found many questions here about storing values in viewstate, but haven't found
I found many way for redirect to previous page after login and example :
I found many pages of my maintenance website inherits a base page which overrides
i found many related questions here. I have a simple java program . it
I've found many ways to make the TWebBrowser show a modeless print dialog box,
I have found many similar posts and even tried to find out how to

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.