Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea comments fix #11

Merged
merged 2 commits into from
Feb 10, 2013
Merged

Idea comments fix #11

merged 2 commits into from
Feb 10, 2013

Conversation

brodul
Copy link
Contributor

@brodul brodul commented Feb 9, 2013

Currently commenting ideas is broken. If someone wants to comment an idea just new idea is generated. Because when someone submits the comment form, the target idea param is ignored in add_idea view. Resulting the target to be None and making a new idea.

Please see the test commit.

@@ -130,7 +130,7 @@ class AddIdeaSchema(formencode.Schema):
@view_config(permission='post', route_name='idea_add',
renderer='templates/idea_add.pt')
def idea_add(request):
target = request.GET.get('target')
target = request.POST.get('target') or request.GET.get('target')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably better spelled as "target = request.params.get('target')" (request.params looks in GET first, then POST).

@brodul
Copy link
Contributor Author

brodul commented Feb 10, 2013

Hmm, there seems to be a problem with request.params:

(Pdb) l
130     @view_config(permission='post', route_name='idea_add',
131                  renderer='templates/idea_add.pt')
132     def idea_add(request):
133         target = request.params.get('target')
134         import pdb; pdb.set_trace()
135  ->     session = DBSession()
136         if target:
137             target = Idea.get_by_id(target, with_joinedload=False)
138             if not target:
139                 return HTTPNotFound()
140             kind = 'comment'
(Pdb) request.params
{}
(Pdb) request.POST
{'form.submitted': u'Shoot', 'title': u'My comment', 'text': u'My comment is cool', 'target': u'1', 'tags': u'abc def, bar'}
(Pdb) request.GET
{}

Any idea why?

@mcdonc
Copy link
Member

mcdonc commented Feb 10, 2013

No. I see this:

> /home/chrism/projects/shootout/shootout/views.py(143)idea_add()
-> session = DBSession()
(Pdb) n
> /home/chrism/projects/shootout/shootout/views.py(144)idea_add()
-> if target:
(Pdb) p target
None
(Pdb) p request.GET
GET([])
(Pdb) p request.POST
MultiDict([('_csrf', u'f76241bcafad6d2e9f70f57e690b910b6dd6bf50'), ('title', u'title'), ('tags', u'tag1, tag2'), ('text', u'hello'), ('target', u'3'), ('form.submitted', u'Shoot')])
(Pdb) p request.params
NestedMultiDict([('_csrf', u'f76241bcafad6d2e9f70f57e690b910b6dd6bf50'), ('title', u'title'), ('tags', u'tag1, tag2'), ('text', u'hello'), ('target', u'3'), ('form.submitted', u'Shoot')])

@domenkozar
Copy link
Member

@brodul are you using DummyRequest?

@mcdonc mcdonc merged commit bfff163 into Pylons:master Feb 10, 2013
@mcdonc
Copy link
Member

mcdonc commented Feb 10, 2013

I fixed it in the merge.

@brodul
Copy link
Contributor Author

brodul commented Feb 10, 2013

@iElectric yes I do

@domenkozar
Copy link
Member

See 40a435a

@brodul
Copy link
Contributor Author

brodul commented Feb 10, 2013

Ok, tnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants