Skip to content

[FIX] Get attributes on the class instead of recordsets#50

Merged
guewen merged 1 commit into
OCA:11.0from
subteno-it:11.0-fix-queue-property-compatibility
Feb 8, 2018
Merged

[FIX] Get attributes on the class instead of recordsets#50
guewen merged 1 commit into
OCA:11.0from
subteno-it:11.0-fix-queue-property-compatibility

Conversation

@Garamotte
Copy link
Copy Markdown

Even if the recordset is empty, this is still an instance of the class, so the @Property methods are called. As this type of method is usually run on a single record, they need self.ensure_one(), which crashes when evaluated on a recordset, preventing the server to start when queue_job is installed.

Getting the attributes on the class itself instead of using an empty recordset avoids evaluating property methods.

This reverts commit 49d8f37, which was a hack for a single attribute name instead of a global fix.

Even if the recordset is empty, this is still an instance of the class,
so the @Property methods are called. As this type of method is usually
run on a single record, they need self.ensure_one(), which crashes when
evaluated on a recordset, preventing the server to start when queue_job
is installed.

Getting the attributes on the class itself instead of using an empty
recordset avoids evaluating property methods.

This reverts commit 49d8f37.
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 6, 2018

Coverage Status

Coverage decreased (-0.2%) to 78.136% when pulling 4ebb245 on syleam:11.0-fix-queue-property-compatibility into ba5522f on OCA:11.0.

Copy link
Copy Markdown
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

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

Clever! Frustrated I didn't thought about it, but you make my day 😂

Comment thread queue_job/models/base.py
job_methods.add(attr)
job_methods = [
method for __, method
in inspect.getmembers(self.__class__, predicate=inspect.ismethod)
Copy link
Copy Markdown
Member

@guewen guewen May 22, 2018

Choose a reason for hiding this comment

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

In the class, the methods are not yet methods but functions, because what we are inspecting at this point is the decorated function I guess.

guewen pushed a commit to guewen/queue that referenced this pull request May 22, 2018
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API was
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

The problem of the crash was that, as the introspection basically uses a
'getattr' on every attribute of the instance, and the '_cache' method
could be called on an empty recordset, which is not supported.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
guewen pushed a commit to guewen/queue that referenced this pull request May 22, 2018
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
guewen pushed a commit to guewen/queue that referenced this pull request May 25, 2018
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
eantones pushed a commit to nuobit/queue that referenced this pull request Oct 16, 2020
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
romi477 pushed a commit to romi477/queue that referenced this pull request Oct 25, 2021
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
bizzappdev pushed a commit to BizzAppDev-Systems/queue that referenced this pull request Nov 23, 2023
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
bizzappdev pushed a commit to BizzAppDev-Systems/queue that referenced this pull request Nov 23, 2023
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
nguyenminhchien pushed a commit to nguyenminhchien/queue that referenced this pull request Nov 25, 2023
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
nguyenminhchien pushed a commit to nguyenminhchien/queue that referenced this pull request Nov 29, 2023
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
nguyenminhchien pushed a commit to nguyenminhchien/queue that referenced this pull request Dec 4, 2023
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 19, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 24, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 24, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 24, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 7, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 7, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 7, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 8, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 9, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 11, 2024
The automatic registration of job methods and their defaut channel
has been a bit chaotic. The initial version for the new Odoo API could
crashing as soon as a method was decorated by @Property. There is
such a property in the code code, the method '_cache'.

The problem of the crash was that, the introspection basically uses a
'getattr' on every attribute of the instance. The '_cache' method
could then be called on an empty recordset, which is not supported by
'_cache'.

A first correction (49d8f37) was to naively skip the '_cache' method
from the introspection.

In any case, it is wrong to access the property of an instance only to
instrospect its members.  That's why the correction 4ebb245 changed the
inspection from the instance to the class.

Properties are no longer accessed, however this correction was not
correct for Python 3. When members of the class are introspected, they
are neither bound neither unbound methods. they are mere functions.

The change here is to lookup for functions. _register_job must now takes
the model as input argument, because there is no way to get the name of
the model from the function.

Closes OCA#64
Follows OCA#50
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.

4 participants