[FIX] Get attributes on the class instead of recordsets#50
Merged
Merged
Conversation
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.
guewen
approved these changes
Feb 8, 2018
Member
guewen
left a comment
There was a problem hiding this comment.
Clever! Frustrated I didn't thought about it, but you make my day 😂
lmignon
approved these changes
Feb 8, 2018
guewen
reviewed
May 22, 2018
| job_methods.add(attr) | ||
| job_methods = [ | ||
| method for __, method | ||
| in inspect.getmembers(self.__class__, predicate=inspect.ismethod) |
Member
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.