[issue18978] Allow urllib.request.Request subclasses to override method

2014-02-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1afbd851d1c1 by R David Murray in branch 'default':
whatsnew: Request.method can be overridden in subclasses (#18978).
http://hg.python.org/cpython/rev/1afbd851d1c1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-28 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Thanks for the this change, Jason. Docs could be updated to reflect this change 
(using ..versionchanged: directive). Thank you!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6d6d68c068ad by Jason R. Coombs in branch 'default':
Issue #18978: Allow Request.method to be defined at the class level.
http://hg.python.org/cpython/rev/6d6d68c068ad

New changeset 2b2744cfb08f by Jason R. Coombs in branch 'default':
Issue #18978: A more elegant technique for resolving the method
http://hg.python.org/cpython/rev/2b2744cfb08f

New changeset 061eb75339e2 by Jason R. Coombs in branch 'default':
Issue #18978: Add tests to capture expected behavior for class-level method 
overrides.
http://hg.python.org/cpython/rev/061eb75339e2

New changeset 8620aea9bbca by Jason R. Coombs in branch 'default':
Close #18978: Merge changes.
http://hg.python.org/cpython/rev/8620aea9bbca

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7f13d5ecf71f by Jason R. Coombs in branch 'default':
Issue #18978: Update docs to reflect explicitly the ability to set the 
attribute at the class level.
http://hg.python.org/cpython/rev/7f13d5ecf71f

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

New submission from Jason R. Coombs:

In Python 2.x and 3.2, I used to use a Request subclass I created for 
overriding the method used:

class MethodRequest(request.Request):
def __init__(self, *args, **kwargs):

Construct a MethodRequest. Usage is the same as for
`urllib.request.Request` except it also takes an optional 
`method`
keyword argument. If supplied, `method` will be used instead of
the default.

if 'method' in kwargs:
self.method = kwargs.pop('method')
return request.Request.__init__(self, *args, **kwargs)

def get_method(self):
return getattr(self, 'method', request.Request.get_method(self))

In Python 3.3, which now supports a method parameter, it broke this paradigm 
(because the method is stored in the instance and is always set to None in 
__init__ if not specified).

I believe a paradigm where the method is stored as a class attribute and 
possibly overridden in an instance would be much better, allowing for 
subclasses to simply and directly override the method. For example:

class HeadRequest(MethodRequest):
method = 'HEAD'

That straightforward example works very well if method is allowed to be a class 
attribute, but won't work at all if 'method' is always set as an instance 
attribute in __init__.

And while it's possible for HeadRequest to override __init__, that requires 
HeadRequest to override that entire signature, which is less elegant than 
simply setting a class attribute.

For Python 3.4, I'd like to adapt the Request class to allow the Method to be 
defined at the class level (while still honoring customization at the instance 
level).

--
components: Library (Lib)
messages: 197281
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: Allow urllib.request.Request subclasses to override method
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Hi Jason, 

Agree with you. This design change could be valuable in extending 
urllib.request.Request

Thanks!

--
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've created a clone in which to draft this work.

--
hgrepos: +208

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs jar...@jaraco.com:


--
keywords: +patch
Added file: http://bugs.python.org/file31676/6d6d68c068ad.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs jar...@jaraco.com:


Added file: http://bugs.python.org/file31677/2b2744cfb08f.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Changes by Jason R. Coombs jar...@jaraco.com:


Added file: http://bugs.python.org/file31678/061eb75339e2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18978] Allow urllib.request.Request subclasses to override method

2013-09-08 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've added tests to capture the new behavior.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18978
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com