pyfacebook
pyfacebook copied to clipboard
AssertionError When GAE Is Installed But Not Used
In the situation where you have GAE accessible on your system's path, but it is not actually being used (e.g. you're currently developing a Pylons project that doesn't use GAE) there is a problem when using the urlread function, which is defined near the top of pyfacebook.py.
Because GAE is on the system, line 79 ("from google.appengine.api import urlfetch") does not raise an import error, so the GAE version of the urlread function is used. However, when it is invoked in this situation it raises an AssertionError with this explanation: 'No api proxy found for service "urlfetch"'. This is probably caused by the fact that GAE isn't actually running in this case.
The quickest fix is just to except this error and use the default behavior:
91c91,92
< result = urlfetch.fetch(url, method=method,
---
> try:
> result = urlfetch.fetch(url, method=method,
92a94,96
> except AssertionError:
> res = urllib2.urlopen(url, data=data)
> return res.read()
There's probably a better, long-term fix for this problem though.