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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:20:18+00:00 2026-05-24T12:20:18+00:00

this is very specific to what I am trying to do so I start

  • 0

this is very specific to what I am trying to do so I start describing what it is:

  • a Pyramid app serving plots like http://localhost:6543/path/to/myplot/plot001.png
  • if the plot is not available another image is served (work.png)
  • another part is the deform view which provides a HTML form to enter the configuration for a plot like: http://localhost:6543/path/to/myplot/plot001.png?action=edit. Note here the query string “action=edit”.
  • the configuration consists of datafile, templates etc.
  • the form has save (to save the config) and render buttons (http://localhost:6543/path/to/myplot/plot001.png?action=render). Rendering results into a png file which then is used in a static way.

I figured out all the pieces like rendering using Matplotlib etc. but I am new to Pyramid and Deform. I also have a working view that serves the plot from file. The deform form kind of works, too. At the moment it is unclear to me how to best structure the ULRs to distinguish the serve, edit and render usecases. I guess in Pyramid talk this means how to configure the routes for serve_view and edit_view.

__init__.py:
    config.add_route('serve_route', 
        '/{project_name}/testruns/{testrun_name}/plots/{plot_name}.png')
    config.add_route('edit_route', 
        '/{project_name}/testruns/{testrun_name}/plots/{plot_name}.png')
# can I use query strings like "?action=edit" here to distinguish the difference?


views.py:
@view_config(context=Root, route_name='serve_route')
def plot_view(context, request):
... 
@view_config(context=Root, renderer='bunseki:templates/form.pt', route_name='edit_route')
def edit_view(request):
...

I the Pyramid manual I could not find reference how to set parameters in the route. I guess a pointer to some documentation or sample would be sufficient and I can figure out the details myself. Thank you!

  • 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-24T12:20:19+00:00Added an answer on May 24, 2026 at 12:20 pm

    There are two ways to do this depending on what you prefer for separating your code.

    1. Put all of the logic into your view, separated by ‘if’ statements on request.GET.get('action').

      config.add_route('plot', '/{project_name}/testruns/{testrun_name}/plots/{plot_name}.png')
      config.scan()
      
      @view_config(route_name='plot')
      def plot_view(request):
          action = request.GET('action')
          if action == 'edit':
              # do something
              return render_to_response('bunseki:templates/form.pt', {}, request)
      
          # return the png
      
    2. Register multiple views and delegate between them using Pyramid’s view lookup mechanics.

      config.add_route('plot', '/{project_name}/testruns/{testrun_name}/plots/{plot_name}.png')
      config.scan()
      
      @view_config(route_name='plot')
      def plot_image_view(request):
          # return the plot image
      
      @view_config(route_name='plot', request_param='action=edit',
                   renderer='bunseki:templates/form.pt')
      def edit_plot_view(request):
          # edit the plot
          return {}
      
      # etc..
      

    Hope this helps. It’s an excellent example of registering a single url pattern, and using different views for different types of requests on that url.

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

Sidebar

Related Questions

This is a very specific question for a Google Chrome extension. http://www.meebo.com/mobile/ This page
I'm trying to investigate a very long start up time for my app and
This is a very specific question regarding MySQL as implemented in WordPress . I'm
This is a very specific question which will probably earn me the tumbleweed badge,
I apologise in advance if this question isn't very specific. Would it be possible
This is a very narrow and specific question, but I know there are someone
First of I'm very sorry but this questions is not so so specific. All
I used this side to create my demo application http://windowsclient.net/learn/video.aspx?v=314683 The site was very
I'm trying to build a very specific editor with syntax highlight. I've made all
I am trying to cut down jQuery to a very specific set of functions

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.