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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:30:24+00:00 2026-05-11T17:30:24+00:00

I am new to Python (I am getting out of PHP because of how

  • 0

I am new to Python (I am getting out of PHP because of how increasingly broken it is), and I am racing through porting my old code. One thing:

I have a file /foo.py with functions index() and bar(), so, with the publisher I can access http://domain/foo/bar and http://domain/foo as the documentation suggests.

How can I have it such that I can do:

http://domain/foo/bar/a1/a2/a3/an/…

Such that the publisher launches bar() and then I can access the URL to obtain /a1/a2/…
All I get is Forbidden 🙂 (I don’t want to use mod_rewrite on everything)

Oh, im on 2.5.2
Thanks in advance

UPDATE: The ideal solution would be for the publisher to launch the furthest-right resolution in the URL it can, and simply make a1/a2/a3.. accessible through the apache module. Maybe a combination of an apache directive and publisher?

SOLVED (ish):
The answer of the magic call() method and so on is juicy! Although I think I will modify the publisher or write my own to inspect objects in a similar way using furthest-right matching, then allowing the furthest-right to access the URL using apache module. Thanks all!

  • 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-11T17:30:25+00:00Added an answer on May 11, 2026 at 5:30 pm

    You would have to have an object bar.a1.a2.a3.an defined within your foo.py module. Basically, the publisher handler replaces the slashes in the URL with dots, and tries to find some Python object with that name.

    Here’s something wacky you could try: in foo.py:

    class _barclass(object):
        def __init__(self, parent, name):
            if parent and name:
                self.path = parent.path + '/' + name
                setattr(parent, name, self)
            else:
                self.path = ''
        def __getattr__(self, name):
            return _barclass(self, name)
        def __call__(self):
            # do your processing here
            # url path is contained in self.path
    
    bar = _barclass(None, None)
    

    Although this is kind of straining the bounds of what the publisher is meant to do – you might be better off writing your own handlers from scratch. (Or using something like Django.)

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

Sidebar

Related Questions

I am new to Python, and I'm working on writing some database code using
I am very new to python, about one month, and am trying to figure
I am new to Python and Web.py, but I am tearing my hair out
I'm relatively new to python/django. I'm having an issue with sending to IDs through
I am new to python and struggling to find how to control the amount
I'm relatively new to Python and am having problems programming with Scapy, the Python
I am extremely new to python, having started to learn it less than a
I am really new to Python and I have been looking for an example
I'm new to python, and have a list of longs which I want to
I'm new to python, so please excuse what is probably a pretty dumb question.

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.