Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

What happened to module 'openerp.http'?

By
Michael Watchorn
on 2/24/14, 2:09 PM 3,916 views

Why do I get ImportError: No module named http ?

When installing my module I get the following error:

  File "/home/michael/workspace/openerp/server/openerp/addons/my_punchcard/controllers/my_controller.py, line 1, in <module>
     import openerp.http as http
ImportError: No module named http 
Here's line 1 of my code:
import openerp.http as http

so I tried this instead:
 import openerp.addons.web.http as http 

but then I get this error which says it can't find the route attribute.
  File "/home/michael/workspace/openerp/server/openerp/addons/my_punchcard/controllers/my_controller.py", line 48, in my_punchcard 
       @http.route('/web/my_page', type="http")
AttributeError: 'module' object has no attribute 'route'


I am running Version 7.0-20131203-002409 on an Ubuntu server. I'm developing in Eclipse, which shows a red circle with a white X through it by the original Line 1. So I'm guessing Eclipse knows there's no http in openerp.
My code is like that from doc.openerp.com/trunk/web/web_controllers

1

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 2/24/14, 2:34 PM

Try with: from openerp.addons.web import http as http

Also, Check your eclipse project configuration "PATH"

I still get: AttributeError: 'module' object has no attribute 'route'.

Michael Watchorn
on 2/24/14, 2:51 PM

Check your URL Patterns (as described in doc.openerp.com/trunk/web/web_controllers). Is your "my_page" under web ?

Med Said BARA
on 2/24/14, 3:33 PM

Be careful, the doc is for the trunk (8.0dev) not for 7.0.

Med Said BARA
on 2/24/14, 3:47 PM

Thanks Med Said BARA, I'm wondering if the documentation for trunk is not applicable to V7. That would explain why route doesn't work for me. I found an example from web_diagram that I tried to modify:

<pre><code> from openerp.addons.web.http import Controller, httprequest

class MyClass(Controller): _cp_path = "/web/mypage"

@httprequest
def index(self):
    return "<html><head></head><body>TESTING 123</body></html>"

</code></pre>

Michael Watchorn
on 2/24/14, 5:19 PM

Not exactly as I wanted that to be posted. However no matter what URL i try (or _cp_path I set) I can't get it to find the document. I would have thought the return would do it. However maybe I need a view?

However at least with this code I am getting no errors when I restart the server.

Michael Watchorn
on 2/24/14, 5:20 PM

openerp.http.httprequest(f) Deprecated since version 8.0.

Med Said BARA
on 2/24/14, 8:20 PM

Just to confirm, and as stated here: https://doc.openerp.com/trunk/server/routing/ . route() is for V8

Med Said BARA
on 2/24/14, 8:23 PM

That is certainly my problem. I was using code in version 7.0 meant for version 8. I now use a simpler _cp_path='/my_module' and the function name becomes the final part of the URL. I saw in the web_diagram controller which used @httprequest, that it had a function named index. And Point-of-sale has a _cp_path of '/pos', which made me think that perhaps my path was too long. Now i also understand why @httprequest doesn't specify the complete URL the way route does, @httprequest accesses any function with @httprequest declared above it using the function name rather than the @route argument.

Michael Watchorn
on 2/24/14, 11:32 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/24/14, 2:09 PM
Seen: 3916 times
Last updated: 3/16/15, 8:10 AM