Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError (setRequestID, unexpected keyword argument) on AR Creation #334

Merged
merged 8 commits into from
Oct 30, 2017

Conversation

nihadness
Copy link
Contributor

@nihadness nihadness commented Oct 30, 2017

For detailed information about issue, see #325

Current behavior
ARs are created, but a Traceback occurs in the background.

Traceback:

Traceback (most recent call last):
  File "/Users/rbartl/develop/ridingbytes/liscon/liscon.lims/eggs/Products.Archetypes-1.9.17-py2.7.egg/Products/Archetypes/BaseObject.py", line 144, in initializeArchetype
    self.setDefaults()
  File "/Users/rbartl/develop/ridingbytes/liscon/liscon.lims/eggs/Products.Archetypes-1.9.17-py2.7.egg/Products/Archetypes/BaseObject.py", line 420, in setDefaults
    self.Schema().setDefaults(self)
  File "/Users/rbartl/develop/ridingbytes/liscon/liscon.lims/src/bika.lims/bika/lims/monkey/Schema.py", line 72, in setDefaults
    mapply(mutator, *args, **kw)
  File "/Users/rbartl/develop/ridingbytes/liscon/liscon.lims/eggs/Products.Archetypes-1.9.17-py2.7.egg/Products/Archetypes/utils.py", line 111, in mapply
    return method(*args, **kw)
  File "/Users/rbartl/develop/ridingbytes/liscon/liscon.lims/src/bika.lims/bika/lims/__init__.py", line 205, in wrapper
    return func(*args, **kwargs)
TypeError: setRequestID() got an unexpected keyword argument ‚mimetype‘

Expected behavior after this PR
ARs are created w/o Tracebacks

I justified why I added unused parameter to the method here:
#325 (comment)

@nihadness nihadness changed the title Issue 325- Traceback on AR creation Fix TypeError (setRequestID, unexpected keyword argument) on AR Creation Oct 30, 2017
@@ -1916,7 +1916,7 @@ def getRequestID(self):
return self.getId()

@deprecated('[1703] Use setId(new_id) instad')
def setRequestID(self, new_id):
def setRequestID(self, new_id, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

I see this method is tagged as deprecated . I think would be better to find out where this function is called and replace the call by the one suggested in the deprecation message setId(new_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since RequestID is a field in AR Schema, it is called by default while an AR object is being created. We do not call it anywhere from code currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, the AR create process passes all field values to bika.lims.utils.analysisrequest.create_analysisrequest:
https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/browser/analysisrequest/add2.py#L1748
which calls processForm method of the AR:
https://github.com/senaite/bika.lims/blob/senaite-integration/bika/lims/utils/analysisrequest.py#L75
As far as I know, this looks up the default mutator of the field and calls it with the given value. So we have to probably overwrite that default mutator in the Schema

@ramonski ramonski merged commit d7a2723 into senaite:senaite-integration Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants