×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    Tokyo, Japan
    Posts
    25

    [announce] waplib module 0.0.3: tiny module to extend urllib module

    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

  2. #2
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    Hello Hiisi ,

    Great addition to PyS60

    What a first great announce

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    28

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    So, forgive for not having tried the module yet , but what is waplib approach to avoid asking user for the proxy settings?

    thanks

  6. #6
    Registered User
    Join Date
    Jul 2008
    Location
    Tokyo, Japan
    Posts
    25

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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

  7. #7
    Registered User
    Join Date
    Jul 2008
    Location
    Tokyo, Japan
    Posts
    25

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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 16:43.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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

  9. #9
    Registered User
    Join Date
    Jul 2008
    Location
    Tokyo, Japan
    Posts
    25

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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]

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: [announce] waplib module 0.0.3: tiny module to extend urllib module

    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

    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

Similar Threads

  1. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43

Posting Permissions

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