You Are Here:

Community: Developer Discussion Boards

#1 Old [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-24, 18:07

Join Date: Jul 2008
Posts: 25
Location: Tokyo, Japan
Hiisi
Offline
Registered User
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 to
  • add 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
Reply With Quote

#2 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-24, 22:40

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Hello Hiisi ,

Great addition to PyS60

What a first great announce

BR
Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#3 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-25, 10:07

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Hi Hiisi,

Indeed its a great addition.

Quote:
Originally Posted by Hiisi View Post
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
Reply With Quote

#4 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-25, 20:15

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
Great work done.
Twitter is saving loads of my effort, a further enhancement from your side will make my job pretty easy.


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#5 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-29, 01:41

Join Date: Aug 2008
Posts: 28
skewlboy
Offline
Registered User
So, forgive for not having tried the module yet , but what is waplib approach to avoid asking user for the proxy settings?

thanks
Reply With Quote

#6 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-29, 14:54

Join Date: Jul 2008
Posts: 25
Location: Tokyo, Japan
Hiisi
Offline
Registered User
Quote:
Originally Posted by skewlboy View Post
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
Reply With Quote

#7 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-29, 15:09

Join Date: Jul 2008
Posts: 25
Location: Tokyo, Japan
Hiisi
Offline
Registered User
And, I've written a practical guide: "How to display text query on standby screen".

EDIT: I use this method in PyTwitterS60.
Last edited by Hiisi : 2008-08-29 at 17:43.
Reply With Quote

#8 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-29, 15:23

Join Date: Feb 2008
Posts: 2,544
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by Hiisi View Post
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


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#9 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-29, 17:32

Join Date: Jul 2008
Posts: 25
Location: Tokyo, Japan
Hiisi
Offline
Registered User
Quote:
Originally Posted by gaba88 View Post
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]
Reply With Quote

#10 Old Re: [announce] waplib module 0.0.3: tiny module to extend urllib module - 2008-08-30, 08:05

Join Date: Feb 2008
Posts: 2,544
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
Quote:
Originally Posted by Hiisi View Post
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


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Carbide.j 1.5 and Netbeans 5.5 beta 2 ovjo12 Mobile Java Tools & SDKs 5 2007-06-11 06:43

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia