Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
alternative to match_param accepting a dict
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jason  
View profile  
 More options Aug 29 2012, 11:20 am
From: Jason <ja...@deadtreepages.com>
Date: Wed, 29 Aug 2012 08:20:52 -0700 (PDT)
Local: Wed, Aug 29 2012 11:20 am
Subject: alternative to match_param accepting a dict

I noticed the bug in Pyramid where a match_param argument to view_config
would not allow dicts due to them being unhashable
(https://github.com/Pylons/pyramid/issues/425). This fix is to no longer
accept dicts as a parameter.

Would it be an acceptable idea to allow a two dimensional tuple (('param',
'value'), ('paramtwo', 'value2')). It seems inconvenient that to work with
the match_param I have to parse strings and format them to the format
specification instead of using some kind of mapping.

My use case might be kind of strange, but I still think using string format
for meaningful data instead of a mapping is weirder. My use case is to
extend the view_config class in the following manner to automate adding a
dynamic match_param argument:

from pyramid.view import view_config
class action_config(view_config):
    def __call__(self, wrapper):
        settings = self.__dict__
        # if no name is given use the name of the function to match
        # against the 'action' matchdict parameter
        name = settings.get('name', wrapper.__name__)
        # add custom predicate to view config
        try:
            settings.setdefault('match_param', {})['action'] = name
        except TypeError:
            raise Exception('match_param must be a dict')
        return view_config.__call__(self, wrapper)

--
Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »