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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:15:51+00:00 2026-06-18T18:15:51+00:00

I want to create a simple Zope2 product that implements a virtual folder where

  • 0

I want to create a simple Zope2 product that implements a “virtual” folder where a part of the path is processed by my code. A URI of the form

/members/$id/view

e.g.

/members/isaacnewton/view

should be handled by code in the /members object, i.e. a method like members.view(id='isaacnewton').

The Zope TTW Python scripts have traverse_subpath but I have no idea how to do this in my product code.

I have looked at the IPublishTraverse interface publishTraverse() but it seems very generic.

Is there an easier way?

  • 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-18T18:15:52+00:00Added an answer on June 18, 2026 at 6:15 pm

    Still the easiest way is to use the __before_publishing_traverse__ hook on the members object:

    from zExceptions import Redirect
    
    
    def __before_publishing_traverse__(self, object, request):
        stack = request.TraversalRequestNameStack
        if len(stack) > 1 and stack[-2] == 'view':
            try:
                self.request.form['member_id'] = stack.pop(-1)
                if not validate(self.request['member_id']):
                    raise ValueError
            except (IndexError, ValueError):
                # missing context or not an integer id; perhaps some URL hacking going on?
                raise Redirect(self.absolute_url())  # redirects to `/members`, adjust as needed
    

    This method is called by the publisher before traversing further; so the publisher has already located the members object, and this method is passed itself (object), and the request. On the request you’ll find the traversal stack; in your example case that’ll hold ['view', 'isaacnewton'] and this method moves 'isaacnewton' to the request under the key 'member_id' (after an optional validation).

    When this method returns, the publisher will use the remaining stack to continue the traverse, so it’ll now traverse to view, which should be a browser view that expects a member_id key in the request. It then can do it’s work:

    class MemberView(BrowserView):
        def __call__(self):
            if 'member_id' in self.request.form:  # Huzzah, the traversal worked!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple bit of JS code that creates an image
JavaScript. I want to create simple script, that will be resize loaded image using
I want to create a simple app that shows me the city of the
I want to create a simple user registration form with First / Last name,
I want to create a simple python script that look into folders and subfolders
I want to create simple app, that would use css and js. But I
I want to create a simple app that draws a simple line on screen
I want to create simple form to validate each row of mysql_fetch_array if it's
I want to create simple Spring MVC Hello world application that runs under Jetty
Just want to create a simple contact form in Symfony 2.1. How? ContactForm.php: namespace

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.