Openupgrade Comparions Config: problem with connection

Asked by Jeroen_monkeytail

Connection failed.

<Fault 'LocalService' object has no attribute 'execute_kw': 'Traceback (most recent call last):\n File "/home/jeroen/workspace/pospub/source/code/openerp5/openerp-server/netsvc.py", line 244, in dispatch\n result = LocalService(service_name)(method, *params)\n File "/home/jeroen/workspace/pospub/source/code/openerp5/openerp-server/netsvc.py", line 73, in __call__\n return getattr(self, method)(*params)\nAttributeError: \'LocalService\' object has no attribute \'execute_kw\'\n'>

I get this error, when I start a 6.0 Openupgrade server, and try to make connection with a (normal) 5.0 server.
5.0 server is running on port 8069, 6.0 server on different port

what could be wrong?

Question information

Language:
English Edit question
Status:
Expired
For:
OpenUpgrade Server Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jeroen_monkeytail (n-jeroen) said :
#1

In /openupgrade/6.0/bin/addons/openupgrade_records/model/comparison_config.py

The code is:

    def test_connection(self, cr, uid, ids, context=None):
        try:
            connection = self.get_connection(cr, uid, [ids[0]], context)
            print 'connection: ', connection
            user_model = connection.get_model("res.users")
            print 'user_model: ', user_model
            ids = user_model.search([("login", "=", "admin")])#ids = user_model.search([("login", "=", "admin")])
            print 'ids: ', ids
            user_info = user_model.read(ids[0], ["name"])
            print 'user_info: ', user_info
        except Exception, e:
            raise osv.except_osv(
                _("Connection failed."), unicode(e))
        raise osv.except_osv(
            _("Connection succesful."),
            _("%s is connected.") % user_info["name"]
            )

the result is:
connection: <openerplib.main.Connection object at 0x2418050>
user_model: <openerplib.main.Model object at 0x2418090>
for 'ids' there is no value printed, so something goes wrong with user_model.search_read

If i analyse the openerplib module in the ubuntu terminal, I see:

>>> import openerplib as p

>>> dir(p.main.Model)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'search_read']

>>> p.main.Model.search([("login", "=", "admin")])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Model' has no attribute 'search'

there is a function, called search_read, however when we use this, we also get an error:

>>> p.main.Model.search_read([("login", "=", "admin")])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method search_read() must be called with Model instance as first argument (got list instance instead)

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#2

I assume that you are comparing generated 'OpenUpgrade records' that represent the database layout given the installed modules. For that, you will need to be talking to an older release of the OpenUpgrade server that has the same modules installed + openupgrade_records. It needs to have its records generated too.

Can't tell from the trace if this is your exact problem but it is a good start. However, please note that you only need to take this step for custom or community modules. The step that I think you are performing creates the analysis files which are pregenerated for the official addons.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#3

Our latest messages crossed. With the new info, it looks like a problem with openerplib.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#4

The test in our code for a user called admin is pretty flakey, because its login could be changed in your database. Is that the case?

Revision history for this message
Jeroen_monkeytail (n-jeroen) said :
#5

>>please note that you only need to take this step for custom or community modules.
Agree. This is just for testing purposes, to better understand the Openupgrade module.

>>because its login could be changed in your database
No, it is admin.
the problem seems to be the search function, that appears not to be available openerplib.main.Model ...

I installed openerplib with:
sudo easy_install openerp-client-lib
Searching for openerp-client-lib
Best match: openerp-client-lib 1.1.1
Processing openerp_client_lib-1.1.1-py2.7.egg
openerp-client-lib 1.1.1 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/openerp_client_lib-1.1.1-py2.7.egg
Processing dependencies for openerp-client-lib
Finished processing dependencies for openerp-client-lib

Do you think there might be a problem with this version of openerplib?
Is there a search function available in other versions of openerplib?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#6

For the record, if our own environment has not been rebuilt then we used openerplib 1.0.3 to compare records with version 5. Note that openerplip.main.Model does not directly implement search and other methods because it proxies them through XMLRPC. In your interactive analysis session above you do not show where the connection is created and the model is instanciated, so if you actually did not perform those steps it is to be expected that it says "AttributeError: type object 'Model' has no attribute 'search'". It could still be a very basic problem on your OpenERP 5 side.

Revision history for this message
Jeroen_monkeytail (n-jeroen) said :
#7

This is the code, where the connection is tested:

[comparison_config.py]
    def get_connection(self, cr, uid, ids, context=None):
        if not ids:
            raise osv.except_osv(
                _("Cannot connect"), _("Invalid id passed."))
        conf = self.read(cr, uid, ids[0], context=None)

        print "dir(openerplib): ", dir(openerplib)
        #dir(openerplib):
        # ['AuthenticationError', 'Connection', 'Connector', 'JsonRPCConnector', 'JsonRPCException', 'JsonRPCSConnector', 'Model', 'Service',
        # 'XmlRPCConnector', 'XmlRPCSConnector', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__',
        # 'get_connection', 'get_connector', 'json', 'json_rpc', 'logging', 'main', 'random', 'urllib2', 'xmlrpclib']
        return openerplib.get_connection(
           hostname=conf['server'],
           database=conf['database'],
           login =conf['username'],
           password=conf['password'],
           port =conf['port'],
           )

    def test_connection(self, cr, uid, ids, context=None):
        try:
            connection = self.get_connection(cr, uid, [ids[0]], context)

            print 'connection', connection
            print 'dir(connection): ', dir(connection)
            #connection: <openerplib.main.Connection object at 0x3075b90>
            #dir(connection)
            #dir(connection): ['_Connection__logger', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__',
            #'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
            #'__subclasshook__', '__weakref__', 'check_login', 'connector', 'database', 'get_model', 'get_service', 'get_user_context', 'login',
            #'password', 'set_login_info', 'user_context', 'user_id']

so you are trying to say that it goes wrong on this line:
connection = self.get_connection(cr, uid, [ids[0]], context)
?

if we analyse 'connection':
            #dir(connection): ['_Connection__logger', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__',
            #'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
            #'__subclasshook__', '__weakref__', 'check_login', 'connector', 'database', 'get_model', 'get_service', 'get_user_context', 'login',
            #'password', 'set_login_info', 'user_context', 'user_id']

we see it does not contain the standard openerp class function, like create, write, search etc.
This is not good?

Apparently, something goes wrong here:
        return openerplib.get_connection(
           hostname=conf['server'],
           database=conf['database'],
           login =conf['username'],
           password=conf['password'],
           port =conf['port'],
           )

I now want to look up the function 'get_connection' in openerplib:

jeroen@probook-jeroen:/usr/local/lib/python2.7/dist-packages$ ls -l
total 424
drwxr-sr-x 4 root staff 4096 2011-12-02 13:41 aeroolib-1.0.0.RC4-py2.7.egg
drwxr-sr-x 2 root staff 4096 2013-03-28 13:44 Asterisk
-rw-r--r-- 1 root staff 3687 2012-10-29 11:59 bzr-2.5.1.egg-info
drwxr-sr-x 17 root staff 16384 2012-10-29 11:59 bzrlib
drwxr-sr-x 17 root staff 4096 2012-04-05 16:39 django
-rw-r--r-- 1 root staff 1179 2012-04-05 16:39 Django-1.4.egg-info
-rw-r--r-- 1 root staff 393 2013-04-15 12:30 easy-install.pth
drwxr-sr-x 4 root staff 4096 2013-01-04 15:52 Jinja2-2.6-py2.7.egg
drwxr-sr-x 5 root staff 4096 2011-11-30 13:55 openerp_client-6.0.3-py2.7.egg
-rw-r--r-- 1 root root 14983 2013-04-15 12:30 openerp_client_lib-1.1.1-py2.7.egg
drwxr-sr-x 4 root staff 4096 2013-03-28 13:29 phonenumbers
drwxr-sr-x 2 root staff 4096 2013-03-28 13:29 phonenumbers-5.4b1-py2.7.egg-info
-rw-r--r-- 1 root staff 256 2013-03-28 13:44 py_Asterisk-0.5.1.egg-info
drwxr-sr-x 2 root staff 4096 2013-03-28 13:29 py_Asterisk-0.5.1-py2.7.egg-info
-rw-rw-r-- 1 root staff 332005 2011-11-30 13:45 setuptools-0.6c11-py2.7.egg
-rw-r--r-- 1 root staff 30 2011-11-30 13:51 setuptools.pth
drwxr-sr-x 4 root staff 4096 2013-01-04 15:52 Sphinx-1.1.3-py2.7.egg
drwxr-sr-x 5 root staff 4096 2012-03-28 11:54 werkzeug
drwxr-sr-x 2 root staff 4096 2012-03-28 11:54 Werkzeug-0.8.3-py2.7.egg-info

I try to read the file: openerp_client_lib-1.1.1-py2.7.egg
jeroen@probook-jeroen:/usr/local/lib/python2.7/dist-packages$ less openerp_client_lib-1.1.1-py2.7.egg
"openerp_client_lib-1.1.1-py2.7.egg" may be a binary file. See it anyway?

openerp_client_lib-1.1.1-py2.7.egg appears to be a binary file, there is not a directory with the same name,
like django has:

drwxr-sr-x 17 root staff 4096 2012-04-05 16:39 django
-rw-r--r-- 1 root staff 1179 2012-04-05 16:39 Django-1.4.egg-info

Is openerplib not correctly installed?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) said :
#8

>
> we see it does not contain the standard openerp class function, like create, write, search etc.
> This is not good?
>

It is the model class that provides them, not the connection. However, like I said earlier on, the classes in this library proxy unknown methods over XMLRPC.

>
> Is openerplib not correctly installed?

In an interactive python session, see if what results you get> Here is a sample session.

>>> import openerplib
>>> connection = openerplib.get_connection('localhost', database='mydb', login='admin', password='mypw', port=8069)
>>> user_model = connection.get_model('res.users')
>>> user_model.search([('login', '=', 'admin')])

[1]

>>> user_model.read([1])

[{'groups_id': [1, 2, 3, 5, 6, 7, 8, 9, 13, 14, 15, 16], 'sel_groups_1_2': 2, 'active': True, 'in_group_16': True, 'in_group_10': False, 'in_group_11': False, 'in_group_12': False, 'id': 1, 'in_group_9': True, 'in_group_6': True, 'sel_groups_3': 3, 'new_password': '', 'in_group_5': True, 'company_id': [1, 'Your Company'], 'action_id': [106, 'Home Page'], 'menu_id': [1, 'Menu'], 'sel_groups_7_8': 8, 'company_ids': [1], 'menu_tips': False, 'date': '2013-04-23 11:10:33.514874', 'context_lang': 'en_US', 'password': 'mypw', 'context_tz': False, 'name': 'Administrator', 'sel_groups_13_14_15': 15, 'signature': 'Administrator', 'login': 'admin', 'in_group_4': False, 'user_email': False, 'view': 'extended'}]

Revision history for this message
Launchpad Janitor (janitor) said :
#9

This question was expired because it remained in the 'Open' state without activity for the last 15 days.