Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 920778 - Review Request: python-MultipartPostHandler2 - A handler for urllib2 to enable multipart form uploading
Summary: Review Request: python-MultipartPostHandler2 - A handler for urllib2 to enabl...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bohuslav "Slavek" Kabrda
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-12 17:41 UTC by Miro Hrončok
Modified: 2014-05-25 03:47 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-04-10 01:27:31 UTC
Type: ---
Embargoed:
bkabrda: fedora-review+
gwync: fedora-cvs+


Attachments (Terms of Use)
0.1.4.patch (5.07 KB, patch)
2014-05-25 03:28 UTC, Sergio Basto
no flags Details | Diff
0.1.4.v2.patch (5.14 KB, patch)
2014-05-25 03:47 UTC, Sergio Basto
no flags Details | Diff

Description Miro Hrončok 2013-03-12 17:41:21 UTC
Spec URL: https://raw.github.com/hroncok/SPECS/master/python-MultipartPostHandler2.spec
SRPM URL: https://github.com/downloads/hroncok/SPECS/python-MultipartPostHandler2-0.1.1-2.fc18.src.rpm

Description:
This is MultipartPostHandler plus a fix for UTF-8 systems.
Enables the use of multipart/form-data for posting forms.

Fedora Account System Username: churchyard

Comment 1 Bohuslav "Slavek" Kabrda 2013-03-15 14:52:59 UTC
I'll take this for a review.

Comment 2 Bohuslav "Slavek" Kabrda 2013-03-18 12:57:09 UTC
- I'd advise using %{version} in URL (instead of current 0.1.1).
- pushd/popd seem a bit cleaner than cd/cd -, but that's just my impression :)
- Files in %{python_sitelib} shouldn't be executable, IMHO. If these files really need to be executed by user, I'd suggest placing some stub into %{_bindir}. setuptools' entry_points should do the trick [1]. It might be worth it to create pull request that would introduce usage of entry_points and send it upstream.

[1] http://pythonhosted.org/distribute/setuptools.html#dynamic-discovery-of-services-and-plugins

Comment 3 Miro Hrončok 2013-03-18 15:37:59 UTC
Actually, examining the code makes me think the main() function of this is absolutely useless to the user. The best idea I have is to cut it out of the file, use it as test* and then store it in doc as an example.

* That might not work in Koji, as it requires Internet access and I don't know if that is possible.

Comment 4 Bohuslav "Slavek" Kabrda 2013-03-19 11:36:25 UTC
(In reply to comment #3)
> Actually, examining the code makes me think the main() function of this is
> absolutely useless to the user. The best idea I have is to cut it out of the
> file, use it as test* and then store it in doc as an example.
> 

Yes, that seems like a good approach to me.

> * That might not work in Koji, as it requires Internet access and I don't
> know if that is possible.

No, that's not possible in Koji. The best way is running the test locally and then disabling it for Koji by some condition.

Comment 5 Miro Hrončok 2013-03-21 19:55:57 UTC
Now it is done. The only thing that drives me crazy is that output of test in Pyhton 2 uses newlines and in Pyhton 3 it prints \n. Is there anything I've done wrong, or is it normal bahaviour in P3? Thanks for help.

Spec URL: https://raw.github.com/hroncok/SPECS/master/python-MultipartPostHandler2.spec
SRPM URL: https://github.com/downloads/hroncok/SPECS/python-MultipartPostHandler2-0.1.1-3.fc18.src.rpm

Comment 6 Bohuslav "Slavek" Kabrda 2013-03-22 08:08:27 UTC
The newlines are actually a correct behaviour. In Python 3, the read() method of the opener object returns 'bytes' object. This is because it can't determine the encoding of the URL content prior to reading it.
When you print a 'bytes' object in Python 3, this is exactly what happens. As mentioned in [1], it is up to your program to determine the encoding from the 'bytes' object and then decode it properly into string. Therefore, if you use

print(opener.open(validatorURL, params).read().decode('utf-8'))

everything will work as you expect and it is also actually the "correct" behaviour, so to say.

[1] http://docs.python.org/3/library/urllib.request.html#examples

Anyway, the specfile and SRPM look good, so please fix this nit before importing, the package is


APPROVED

Comment 7 Miro Hrončok 2013-03-22 10:37:45 UTC
(In reply to comment #6)
> Therefore, if you use
> 
> print(opener.open(validatorURL, params).read().decode('utf-8'))
> 
> everything will work as you expect and it is also actually the "correct"
> behaviour, so to say.

Can't say that



+ /usr/bin/python3 MultipartPostHandler-example.py
Traceback (most recent call last):
  File "MultipartPostHandler-example.py", line 29, in <module>
    main()
  File "MultipartPostHandler-example.py", line 26, in main
    validateFile("http://www.google.com")
  File "MultipartPostHandler-example.py", line 19, in validateFile
    print(opener.open(validatorURL, params).read().decode('utf-8'))
UnicodeEncodeError: 'ascii' codec can't encode character '\u2026' in position 1422: ordinal not in range(128)

Comment 8 Bohuslav "Slavek" Kabrda 2013-03-22 10:45:26 UTC
That is of course assuming that the page is really encoded using utf-8. For me, iso-8859-2 works for www.google.com - I guess google adapts that to your actual location. You can try e.g. www.python.org, that is in utf-8 for everyone.

Comment 10 Miro Hrončok 2013-03-22 13:24:14 UTC
New Package SCM Request
=======================
Package Name: python-MultipartPostHandler2
Short Description: A handler for urllib2 to enable multipart form uploading
Owners: churchyard bkabrda
Branches: f17 f18 f19

Comment 11 Miro Hrončok 2013-03-25 13:43:05 UTC
Jon, you have set the flag to + but haven't write your magical "Git done" and I still canote clone it.

Thanks

Comment 12 Gwyn Ciesla 2013-03-25 13:46:11 UTC
Sorry, I had some script issues this weekend due to the python-bugzilla update.  The script is fixed now, but some repos might not have been set up properly.  I've done it manually, try it now.

Comment 13 Miro Hrončok 2013-03-25 13:57:13 UTC
It works. Thanks.

Comment 14 Gwyn Ciesla 2013-03-25 13:57:49 UTC
Excellent, anytime!

Comment 15 Fedora Update System 2013-03-25 15:15:21 UTC
python-MultipartPostHandler2-0.1.1-4.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/python-MultipartPostHandler2-0.1.1-4.fc17

Comment 16 Fedora Update System 2013-03-25 15:16:08 UTC
python-MultipartPostHandler2-0.1.1-4.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-MultipartPostHandler2-0.1.1-4.fc18

Comment 17 Fedora Update System 2013-03-25 22:55:50 UTC
python-MultipartPostHandler2-0.1.1-4.fc18 has been pushed to the Fedora 18 testing repository.

Comment 18 Fedora Update System 2013-04-10 01:27:33 UTC
python-MultipartPostHandler2-0.1.1-4.fc18 has been pushed to the Fedora 18 stable repository.

Comment 19 Fedora Update System 2013-04-10 01:35:38 UTC
python-MultipartPostHandler2-0.1.1-4.fc17 has been pushed to the Fedora 17 stable repository.

Comment 20 Sergio Basto 2013-04-10 02:23:13 UTC
Hi, this is awesome because I'm the publisher of this MultipartPostHandler2 , but I can't consider the author,  because the primary author vanish of MultipartPostHandler .
Since someone consider this useful, I may change the contacts, improve things etc . 
But I'm writing because I like to know where do you use this or where this package is useful ?

Comment 21 Miro Hrončok 2013-04-10 08:19:56 UTC
Hi,
I personally use it in my own dirty scripts, such as this one https://github.com/hroncok/netfabbcloud

There's not package in Fedora, that would depend on this one right now.

Improving thing doesn't seem worthy to me, as it works just fine.

Comment 22 Sergio Basto 2014-05-10 05:10:36 UTC
Hi,
I update MultipartPostHandler2 , and applied your patch python-MultipartPostHandler2-cut-out-main.patch , but python setup.py sdist doesn't include the example, I don't understand what I have to do to be included, in meantime I put sources on github you may download full package here : 
https://github.com/sergiomb2/MultipartPostHandler2/archive/0.1.3.tar.gz

Comment 23 Sergio Basto 2014-05-10 05:12:36 UTC
ah and please, test it for me please , I just can do a limited tests here.

Comment 24 Sergio Basto 2014-05-19 14:01:47 UTC
(In reply to Bohuslav "Slavek" Kabrda from comment #2)

> [1]
> http://pythonhosted.org/distribute/setuptools.html#dynamic-discovery-of-
> services-and-plugins

now the link is : 
https://pythonhosted.org/setuptools/setuptools.html#dynamic-discovery-of-services-and-plugins


May I join to committers of this package ? I'm going make the requests now

Comment 25 Miro Hrončok 2014-05-19 14:26:24 UTC
I don't underestand, why do you want to join the committers?

Comment 26 Sergio Basto 2014-05-19 14:41:21 UTC
to update the package to 0.1.4 basically

Comment 27 Sergio Basto 2014-05-25 03:28:27 UTC
Created attachment 899001 [details]
0.1.4.patch

here is the patch for update MultipartPostHandler2 to 0.1.4

and

git rm python-MultipartPostHandler2-cut-out-main.patch 


I should open another bug but post here was faster

Comment 28 Sergio Basto 2014-05-25 03:47:09 UTC
Created attachment 899012 [details]
0.1.4.v2.patch

sorry , I promise, this is last comment .


Note You need to log in before you can comment on or make changes to this bug.