throw error if 'environ' in extra arg. remove extra_orig. #7
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.
I see the point of having
extra_origis when the user passes in extra arguments that contain original request attributes, we temporarily store them in it. We set the values passed in by user when entering the context and change it back to original values when exiting the context.But actually, I looked into the latest stable version of bottle (0.12.13), the properties of
bottle.requestare all read only, meaning that we can't actually overwrite them. E.g.:In our
boddle.pywe do this to set extra arguments:This is how bottle handles extra properties:
First, if a user passes in
environ='test'as extra argument, it will blow this whole bottle thing up.Then,
bottle.request.userworks because the extra property is stored asbottle.request.ext.userin theself.environdictionary and upon retrieving, there's nouserproperty inrequest, so we go to the dictionary to get it as an extra property. Andfilesandformsare stored asbottle.request.ext.filesandbottle.request.ext.formsin there. That's how bottle prevents its own properties from being overwritten.I don't know if anything else we can do to make it work... this change only fixes the "environ" keyword issue. Not sure what we should do about the other issue. And since original properties can't be overwritten, I removed
extra_orig.