r8-forks / webapp-improved

Automatically exported from code.google.com/p/webapp-improved
Other
0 stars 0 forks source link

webapp2_extras protorpc does not work on Python 2.7 #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Trying to use webapp2_extras.protorpc results in the following import error on 
Python 2.7:

Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 168, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 214, in _LoadHandler
    handler = __import__('.'.join(path[:i]))
  File "/base/data/home/apps/s~exabrot/1.352815502383199276/main.py", line 17, in <module>
    import api
  File "/base/data/home/apps/s~exabrot/1.352815502383199276/api.py", line 6, in <module>
    from webapp2_extras import protorpc
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.0.2/webapp2_extras/protorpc.py", line 30, in <module>
    class ServiceHandler(webapp2.RequestHandler, service_handlers.ServiceHandler):
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases ServiceHandler, RequestHandler

Original issue reported on code.google.com by nickjohn...@google.com on 26 Aug 2011 at 6:44

GoogleCodeExporter commented 9 years ago
I'm guessing this happens because:

- protorpc.service_handlers.ServiceHandler extends webapp.RequestHandler (which 
is webapp2.RequestHandler in the new runtime).
- webapp2_extras.protorpc.ServiceHandler extends webapp2.RequestHandler and 
protorpc.service_handlers.ServiceHandler.

I can provide a workaround for the new runtime.

Did you try to use protorpc directly? 

Original comment by rodrigo.moraes on 26 Aug 2011 at 11:53

GoogleCodeExporter commented 9 years ago
Also: can I have a copy of the google.appengine.ext.webapp code used in the 2.7 
runtime? These things pass my tests but I'm of course using the current SDK 
webapp.

Original comment by rodrigo.moraes on 27 Aug 2011 at 9:15

GoogleCodeExporter commented 9 years ago
Sorry for taking so long to answer to this.

I've been thinking on the subject and the best would be probably to remove 
webapp2_extras.protorpc. It is only usable with the 2.5 runtime, and has no 
reason to exist when webapp2 replaces webapp: it is protorpc that needs to 
support webapp2 in the 2.7 runtime, as it it did with webapp.

Original comment by rodrigo.moraes on 17 Sep 2011 at 8:28

GoogleCodeExporter commented 9 years ago
I am trying to migrate from python2.5 to python2.7 in Google App Engine (SDK 
1.6). And got an error when trying GET ProtoRPC service on dev environment:

  File ".../google_appengine/google/appengine/runtime/wsgi.py", line 174, in Handle
    result = handler(self._environ, self._StartResponse)
  File ".../google_appengine/lib/webapp2/webapp2.py", line 1519, in __call__
    response = self._internal_error(e)
  File ".../google_appengine/lib/webapp2/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File ".../google_appengine/lib/webapp2/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File ".../google_appengine/lib/webapp2/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File ".../google_appengine/lib/webapp2/webapp2.py", line 1040, in __call__
    return self.handler(request, *args, **kwargs)
TypeError: __call__() takes exactly 1 argument (4 given)

If I change: "from protorpc.webapp import service_handlers" to "from 
webapp2_extras.protorpc import service_handlers"
then error the same as described above.

Application created with code as below:
application = 
webapp2.WSGIApplication(service_handlers.service_mapping([('/service', 
SomeService),]))

Could you provide some workaround how to use ProtoRPC with python2.7 in Google 
App Engine?

Original comment by S.S.Kos...@gmail.com on 9 Nov 2011 at 9:12

GoogleCodeExporter commented 9 years ago
I believe the ProtoRPC project should provide a way.

The webapp2_extras.protorpc package will be removed as it makes no sense to 
maintain it anymore.

Original comment by rodrigo.moraes on 10 Nov 2011 at 1:11

GoogleCodeExporter commented 9 years ago
I have the same issue as Comment #4. Per Comment $5, I have created an issue 
for this under protorpc (Issue #38) : 
http://code.google.com/p/google-protorpc/issues/detail?id=38

Original comment by stanleyg...@gmail.com on 24 Jan 2012 at 5:47

GoogleCodeExporter commented 9 years ago
webapp2_extras.protorpc was removed from version 2.4. 

I'd like to support this but there's a bit too much magic involved, so better 
to have it as a separated, actively maintained project (or if protorpc project 
supports it by default).

Original comment by rodrigo.moraes on 24 Jan 2012 at 11:57

GoogleCodeExporter commented 9 years ago
In the meantime, does anybody have a workaround for this?

Original comment by je...@impactschools.net on 6 Feb 2012 at 1:48

GoogleCodeExporter commented 9 years ago
I'd like to mention that ProtoRPC is moving away from the webapp handler (in 
part because of the problem discussed here) and to a simpler WSGI based model.  
There is inadequate documentation at this time, however, I've updated the 
original ProtoRPC project page with an example that uses the new WSGI library.  
You can see it here:

  http://code.google.com/p/google-protorpc/

There is also support for multiple service handlers, however, the forms 
interface has not yet been ported.

Original comment by ra...@google.com on 30 Mar 2012 at 8:07

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I copied and pasted your example on http://code.google.com/p/google-protorpc/ 
and it doesn't work. The new app.yaml files with .app require you to have an 
attribute called app. So I modified my file to use app = 
webapp.WSGIApplication(service_mappings), but then I get the same error as #4. 
Does protorpc on app engine actually work with 2.7 runtime at this point?

Original comment by jzha...@gmail.com on 4 Apr 2012 at 3:20