Python Mechanize + GAEpython Code

I am aware of previous questions regarding mechanization + Google App Engine. Which clean Python library should I use to clean a website? and Engine and Google App Engine .

There is also code here that I cannot get to work with the application engine, throwing

File "D:\data\eclipse-php\testpy4\src\mechanize\_http.py", line 43, in socket._fileobject("fake socket", close=True)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist\socket.py", line 42, in _fileobject
fp.fileno = lambda: None
AttributeError: ’str’ object has no attribute ‘fileno’
INFO 2009-12-14 09:37:50,405 dev_appserver.py:3178] "GET / HTTP/1.1″ 500 -

Anyone want to share their working mechanized code + appengine?

+5
source share
3 answers

I solved this problem, just changed the mechanize._http.py code, on line 43, from:

try:
    socket._fileobject("fake socket", close=True)
except TypeError:
    # python <= 2.4
    create_readline_wrapper = socket._fileobject
else:
    def create_readline_wrapper(fh):
        return socket._fileobject(fh, close=True)

in

try:
    # fixed start -- fixed for gae
    class x:
        pass

    # the x should be an object, not a string,
    # This is the key
    socket._fileobject(x, close=True)
    # fixed ended
except TypeError:
    # python <= 2.4
    create_readline_wrapper = socket._fileobject
else:
    def create_readline_wrapper(fh):
        return socket._fileobject(fh, close=True)
+10
source

, GAE, MStodd, GAEMechanize http://code.google.com/p/gaemechanize/

- , MStodd!

ps: Google, .

don

+1
0

All Articles