Welcome to Omgili,
Omgili ( Oh My God I Love It ;) is a search engine for discussions. With Omgili you can find answers and solutions, debates, discussions, personal experiences, opinions and more... To learn more about Omgili click here.
This is a complete preview of the discussion as it was indexed by Omgili crawlers. Use this preview if the original discussion is unavailable.
Click here to view the original discussion.
[http://discussion.forum.nokia.com/forum/showthread.php?t=142...]
Click here to search for discussions with Omgili discussions search engine.
 |
[announce] waplib module 0.0.3: tiny module to extend urllib module - Developer Discussion Boards
I'd like to announce the release of waplib module 0.0.3, a tiny module to extend API of urllib module.
It overrides urllib module toadd arbitrary HTTP headers set proxy setting easily Standard PyS60 package doesn't contain urllib2 module, so you can't add arbitrary HTTP headers easily.
And PyS60 can't access user's proxy setting.
If you want to enable these features, you have to write following lines in EACH script and USER has to edit EACH script.
Code: import socket import urllib # Proxy Address (USER edits this line) PROXY = {'http': 'http://proxy.address.com:8080'} # Access Point Setting apid = socket.select_access_point() ap = socket.access_point(apid) socket.set_default_access_point(ap) class ExtURLopener(urllib.FancyURLopener): def __init__(self, proxy, headers): urllib.FancyURLopener.__init__(self, proxy) self.addheaders = [] for k, v in headers.iteritems(): self.addheaders.append((k, v)) urllib._urlopener = ExtURLopener(PROXY, {'User-Agent': 'Nokia N73'}) # Access f = urllib.urlopen('http://www.python.org/') f.read() f.close() ap.stop()
With waplib module, you can simplify your script as follows:
Code: import socket import urllib import waplib # Network Setting wap = socket.access_point(waplib.APID_WAP) socket.set_default_access_point(wap) waplib.wap_connection({'User-Agent': 'Nokia N73'}) # Access f = urllib.urlopen('http://www.python.org/') f.read() f.close() wap.stop()
User has to edit 3 lines in waplib module in advance.
Meanwhile, developer doesn't need to ask user to edit his/her script, only need to say 'waplib module is required'.
As a demonstration, I've developed PyTwitterS60, the simplest Twitter client on PyS60.
Twitter API needs basic authentication, so you have to add 'Authorization' to HTTP header with waplib module.
On PyTwitterS60, you can only tweet, but a number of required clicks are only two, so I suppose it's convenient for just tweeting continually.
waplib module and PyTwitterS60 are both licensed under GNU GPL.
And user accepts them AS-IS, WITH ALL FAULTS.
You can download them from my PyS60 page here.
I'll welcome any comments from you
|
 |
|
Hello Hiisi ,
Great addition to PyS60
What a first great announce
BR
Cyke64
|
 |
Hi Hiisi,
Indeed its a great addition.
Quote: : On PyTwitterS60, you can only tweet, but a number of required clicks are only two, so I suppose it's convenient for just tweeting continually.
It will be a good utility for twitters, rather than using browser or messaging
Best Regards,
Croozeus
|
 |
|
Great work done.
Twitter is saving loads of my effort, a further enhancement from your side will make my job pretty easy.
|
 |
|
So, forgive for not having tried the module yet , but what is waplib approach to avoid asking user for the proxy settings?
thanks
|
 |
Quote: : So, forgive for not having tried the module yet , but what is waplib approach to avoid asking user for the proxy settings?
Sorry, it isn't a sophisticated method.
As you know, it's impossible to get proxy settings by PyS60.
You need to fill proxy settings in waplib module by yourself.
waplib module is a very simple module, so probably you can understand what I mean by reading my code
|
 |
|
And, I've written a practical guide: "How to display text query on standby screen".
EDIT: I use this method in PyTwitterS60.
|
 |
Quote: : And, I've written a practical guide: "How to display text query on standby screen".
Hi Hissi
really nice work.
i have a small advice why dont you contribute at the wiki too.
Hope you take the advice seriously
enjoy pythoning
gaba88
|
 |
Quote: : hi Hissi
really nice work.
i have a small advice why dont you contribute at the wiki too.
Hope you take the advice seriously Sorry, but I don't think this is an important topic.
I think it's not worth posting on wiki.
However, if you think it's useful, you can post it by yourself!
It's in the public domain.
[OFFTOPIC]
My handle is "Hiisi", not "Hissi" Hiisi are a kind of tutelary spirits in Finland - Hiisi on Wikipedia (Suomi)
[/OFFTOPIC]
|
 |
Quote: : Sorry, but I don't think this is an important topic.
I think it's not worth posting on wiki.
However, if you think it's useful, you can post it by yourself!
It's in the public domain.
Ok will have a try on the wiki
Quote: : My handle is "Hiisi", not "Hissi" Hiisi are a kind of tutelary spirits in Finland - Hiisi on Wikipedia (Suomi) oh god when i will learn to stop making mistakes in writing names.
hope you will not mind it.
Enjoy Pythoning
Gaba88
|
|
|
|