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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:32:33+00:00 2026-05-12T22:32:33+00:00

Using Marius Gedminas’s excellent blog post , I have created a custom traverser for

  • 0

Using Marius Gedminas’s excellent blog post, I have created a custom traverser for a folder in my site.

This allows me to show: http://foo.com/folder/random_id

Instead of: http://foo.com/folder/object.html?id=random_id

The configuration side works great, I can catch the random_ids and search through my messages for the correct one, ready to display.

My problem is that I’m unsure how to then display the data via my usual page templates – at the TODO point in his original code 😉

if name == 'mycalendar':
            mycalendar = ... # TODO: do something to get the appropriate object
            return mycalendar

Usually I’d use something similar to:

class Test(BrowserPage):

    template = ViewPageTemplateFile('atest.pt')

    def __call__(self):
        return self.template()

But I can’t work out how to do this correctly in the context of the custom traversal.


UPDATE: To be clear I want to avoid adding anything else to the url (No: http://foo.com/folder/random_id/read).

I don’t need the view to be available via any other address (No: http://foo.com/folder/read)

The ZCML for the view I’d like to use is:

<browser:page
  for="foo.interfaces.IFooFolderContainer"
  name="read"
  template="read.pt"
  permission="zope.ManageContent"
/>

I’m guessing (on further advice), something along the lines of:

return getMultiAdapter((mycalendar, self.request), IPageTemplate, name=u'read')

Or even a default view for the object type (a dict in this case) that’s being returned:

<browser:page
  for="dict"
  name="read"
  template="read.pt"
  permission="zope.ManageContent"
/>
  • 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-12T22:32:33+00:00Added an answer on May 12, 2026 at 10:32 pm

    It would be easier to answer your question if you showed what your custom traverser is doing.

    Essentially, you want something like this:

    def publishTraverse(self, request, name):
        if name in self.context:
            return MyMessageView(self.context[name], request)
    
        # fall back to views such as index.html
        view = queryMultiAdapter((self.context, request), name=name)
        if view is not None:
            return view
    
        # give up and return a 404 Not Found error page
        raise NotFound(self.context, name, request)
    

    where MyMessageView can be something as simple as

    class MyMessageView(BrowserPage):
        __call__ = ViewPageTemplateFile('read.pt')
    

    Disclaimer: I’m not sure if the view you instantiate directly will be protected by a security wrapper; make sure your functional tests ensure anonymous users can’t view messages if that’s what you want.

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

Sidebar

Related Questions

Using a site like StackOverflow as an example: I have a table of users,
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I would like to add a button to the current page using html()-function. This
Using SVN you can right click a folder TEST and add it to the
Using jQuery's UI Tabs. This is my code. <div id=tabs> <ul> <li><a href=#tabs-1>Find a
Using Core Data. Let's say we have models for Team and Player. Assume: -Each
We manage a site for a medical charity. They have a number of links
I am making this script that will rotate a needle on a tachometer using
I have a problem with the libxml parser on the iPhone! Im using the

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.