Just out of curiosity, why is the _id getting passed into your view as an
argument?

On Fri, Jun 22, 2012 at 2:37 PM, Joe Dallago <[email protected]> wrote:

> You need to populate the matchdict manually.  Add this to your code:
>
> req.matchdict['templateid'] = 1
>
> Pyramid doesn't actually route the URL, so the matchdict isn't populated.
>
> On Fri, Jun 22, 2012 at 2:10 PM, Toni Mueller <[email protected]> wrote:
>
>>
>> Hi,
>>
>> I want to test a view, but the matchdict doesn't get set up. The
>> application works when I use it via a web browser.
>>
>>
>> The route configuration:
>>
>>    config.add_route('newsletter_create_issue',
>> '%s/createissue/{templateid}' % root_path)
>>
>>
>> In the test case (the test suite is set up with their own registry):
>>
>>    def test_getting_an_issue_list(self):
>>        from pyramid import request
>>        # the same code is in the route configuration, with the number
>> being
>>        # a parameter in that view:
>>        path = '/' + root_path + '/createissue/1'
>>        req = request.Request.blank(path)
>>        req.registry = self.config.registry
>>        # The following bails out, due to the code shown below:
>>        result = getNewsletterIssues(req, 1) # BOOM!
>>
>>
>> def getNewsletterIssues(request, id_):
>>    ...
>>    tid = int(request.matchdict['templateid'])
>>
>>
>> The traceback:
>>
>> ...
>>    tid = int(request.matchdict['templateid'])
>> TypeError: 'NoneType' object is unsubscriptable
>>
>>
>> What am I doing wrong?
>>
>> TIA!
>>
>>
>>
>> Kind regards,
>> --Toni++
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/pylons-discuss?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to