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

  • SEARCH
  • Home
  • 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 5990013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:10:59+00:00 2026-05-22T23:10:59+00:00

I’m trying to figure out how to configure a tool to run whenever a

  • 0

I’m trying to figure out how to configure a tool to run whenever a request is received in cherrypy, using an external configuration file. I’ve read through the examples in the documentation, but these all embed the configuration into the source file, rather than a separate configuration file. I’ve read that tools can be configured externally, but I haven’t found any examples.

Taking the example on the wiki, I’d like to be able to do something logically like this:

tools.print_path = cherrypy.Tool('on_start_resource', {what goes here?})

Suppose I have a file named ‘mytools.py’ in my PYTHONPATH, which I can import using ‘import mytools’, and in this file I have a simple “def print_path(multiplier=1)” method. What do I put in the “{what goes here?}” spot? I’ve tried variations on mytools.print_path and the best I get is this:

CherryPy Checker:
The config entry 'tools.print_path' may be invalid, because the 'print_path' tool was not found.
section: [/]

If anyone could point me in the right direction, I’d be most appreciative.

  • 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-05-22T23:11:00+00:00Added an answer on May 22, 2026 at 11:11 pm

    There is no facility inside of a config file to instantiate a Tool (the cherrypy.Tool(...) part). You need to do that in code. Your ‘mytools.py’ file should look like this:

    def print_path(multiplier=1):
        ...
    cherrypy.tools.print_path = cherrypy.Tool('on_start_resource', print_path)
    

    …and then your config file is used to turn the Tool on for a given URL (and its children):

    [/]
    tools.print_path.on: True
    tools.print_path.multiplier: 23
    

    Just make sure you ‘import mytools’ before processing the config file in your startup script.

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

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.