Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
11980 Lượt xem

Problem:

I wrote a new web controller in a new odoo addon - something like that:

@http.route('/web/somefunction', type='http', auth="none")
def somefunction(self, redirect='/web', **kw):
# render domething

Now if I open the URL with the parameter session_id odoo throws me 404. I also set the database with the parameter db but I think there should be no problem with the database because I use auth in the route definition.

The url:

http://localhost:8069/web/somefunction?db=somedb&session_id=61dd713f86c71c42fd72b92849deba77f451c15c

If I remove the session_id parameter the controller function is found and called.


Further information:

I need to set the session_id because I want to change the id. Here I use the functionality of openerp/http.py (class: Root, function: setup_session).

Also I created the session first (in another function which redirects to the "somefunction" controller function:

new_session = http.root.session_store.new()
new_session.db = request.session.db # just a test

So I use the session id of new_session. In my opinion this should work.


Do you have any ideas?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Fix the line of route tha contains auth=''none

You put none outside of ''

It should be auth='none'

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for the answer. But this was a copy-past-error. This is correct in my code.

Câu trả lời hay nhất

I think this is default behaviour of http://werkzeug.pocoo.org/ tool -- it gets session_id from cookie or from get parameters.


As for redefining sessions, try to check this file: https://github.com/yelizariev/addons-yelizariev/blob/8.0/web_sessions_management/http.py

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
18
thg 8 20
22721
4
thg 10 20
5735
2
thg 3 16
4401
1
thg 7 25
2219
1
thg 5 25
958