Commits

rafek  committed 54f4b81

Rename remote method to method

  • Participants
  • Parent commits c6ad6a2
  • Tags snapshot2

Comments (0)

Files changed (34)

File demos/appstats/protorpc_appstats/__init__.py

 class AppStatsService(remote.Service):
   """Service for getting access to AppStats data."""
 
-  @remote.remote(message_types.VoidMessage, Summary)
+  @remote.method(message_types.VoidMessage, Summary)
   def get_summary(self, request):
     """Get appstats summary."""
     response = Summary()
 
     return response
 
-  @remote.remote(GetDetailsRequest, Details)
+  @remote.method(GetDetailsRequest, Details)
   def get_details(self, request):
     """Get appstats details for a particular timestamp."""
     response = Details()

File demos/appstats/protorpc_appstats/main.py

File contents unchanged.

File demos/echo/main.py

File contents unchanged.

File demos/echo/services.py

 class EchoService(remote.Service):
   """Echo service echos response to client."""
     
-  @remote.remote(EchoData, EchoData)
+  @remote.method(EchoData, EchoData)
   def echo(self, request):
     """Echo method."""
     if request.want_time:

File demos/hello/server/main.py

 
 class HelloService(remote.Service):
     
-  @remote.remote(HelloRequest, HelloResponse)
+  @remote.method(HelloRequest, HelloResponse)
   def hello(self, request):
     return HelloResponse(hello='Hello there, %s!' % request.my_name)
 

File demos/hello/server/services.py

 
 class HelloService(remote.Service):
     
-  @remote.remote(HelloRequest, HelloResponse)
+  @remote.method(HelloRequest, HelloResponse)
   def hello(self, request):
     return HelloResponse(hello='Hello there, %s!' % request.my_name)
 

File demos/tunes_db/client/main.py

File contents unchanged.

File demos/tunes_db/server/forms.py

 
     class HelloService(remote.Service):
 
-      @remote.remote(message_types.VoidMessageType, Hello)
+      @remote.method(message_types.VoidMessageType, Hello)
       def world(self, request):
         response = Hello()
         response.greeting = 'Hello World!'

File demos/tunes_db/server/main.py

File contents unchanged.

File demos/tunes_db/server/model_test.py

File contents unchanged.

File demos/tunes_db/server/tunes_db.py

     return results, continuation
 
 
-  @remote.remote(AddArtistRequest, AddArtistResponse)
+  @remote.method(AddArtistRequest, AddArtistResponse)
   def add_artist(self, request):
     """Add artist to library."""
     artist_name = request.name
 
     return AddArtistResponse(artist_id = unicode(artist.key()))
 
-  @remote.remote(UpdateArtistRequest, UpdateArtistResponse)
+  @remote.method(UpdateArtistRequest, UpdateArtistResponse)
   def update_artist(self, request):
     """Update artist from library."""
     def do_deletion():
     return UpdateArtistResponse(
       artist_updated=db.run_in_transaction(do_deletion))
 
-  @remote.remote(DeleteArtistRequest, DeleteArtistResponse)
+  @remote.method(DeleteArtistRequest, DeleteArtistResponse)
   def delete_artist(self, request):
     """Delete artist from library."""
     def do_deletion():
     return DeleteArtistResponse(
       artist_deleted = db.run_in_transaction(do_deletion))
 
-  @remote.remote(FetchArtistRequest, FetchArtistResponse)
+  @remote.method(FetchArtistRequest, FetchArtistResponse)
   def fetch_artist(self, request):
     """Fetch artist from library."""
     artist_model = model.ArtistInfo.get(request.artist_id)
     return FetchArtistResponse(artist=artist)
       
 
-  @remote.remote(SearchArtistsRequest, SearchArtistsResponse)
+  @remote.method(SearchArtistsRequest, SearchArtistsResponse)
   def search_artists(self, request):
     """Search library for artists."""
     results, continuation = self.__search_info(request,
     return SearchArtistsResponse(artists=results or None,
                                  continuation=continuation or None)
 
-  @remote.remote(AddAlbumRequest, AddAlbumResponse)
+  @remote.method(AddAlbumRequest, AddAlbumResponse)
   def add_album(self, request):
     """Add album to library."""
     def create_album():
 
     return AddAlbumResponse(album_id=unicode(album.key()))
 
-  @remote.remote(UpdateAlbumRequest, UpdateAlbumResponse)
+  @remote.method(UpdateAlbumRequest, UpdateAlbumResponse)
   def update_album(self, request):
     """Update album from library."""
     def do_deletion():
         return False
     return UpdateAlbumResponse(album_updated=db.run_in_transaction(do_deletion))
 
-  @remote.remote(DeleteAlbumRequest, DeleteAlbumResponse)
+  @remote.method(DeleteAlbumRequest, DeleteAlbumResponse)
   def delete_album(self, request):
     """Delete album from library."""
     def do_deletion():
 
     return DeleteAlbumResponse(album_deleted=db.run_in_transaction(do_deletion))
 
-  @remote.remote(FetchAlbumRequest, FetchAlbumResponse)
+  @remote.method(FetchAlbumRequest, FetchAlbumResponse)
   def fetch_album(self, request):
     """Fetch album from library."""
     album_model = model.AlbumInfo.get(request.album_id)
       album = None
     return FetchAlbumResponse(album=album)
 
-  @remote.remote(SearchAlbumsRequest, SearchAlbumsResponse)
+  @remote.method(SearchAlbumsRequest, SearchAlbumsResponse)
   def search_albums(self, request):
     """Search library for albums."""
     def customize_query(request, query):

File demos/tunes_db/server/tunes_db_test.py

File contents unchanged.

File python/gen_protorpc.py

File contents unchanged.

File python/protorpc/definition.py

       """Actual service method."""
       raise NotImplementedError('Method is not implemented')
     remote_method.__name__ = method_name
-    remote_method_decorator = remote.remote(request_definition,
+    remote_method_decorator = remote.method(request_definition,
                                             response_definition)
 
     class_dict[method_name] = remote_method_decorator(remote_method)

File python/protorpc/definition_test.py

File contents unchanged.

File python/protorpc/descriptor_test.py

     expected.number = 10
     expected.label = descriptor.FieldDescriptor.Label.OPTIONAL
     expected.variant = messages.EnumField.DEFAULT_VARIANT
-    expected.type_name = '__main__.MyEnum'
+    expected.type_name = 'descriptor_test.MyEnum'
     expected.default_value = '1'
 
     described = descriptor.describe_field(field)
     class Response(messages.Message):
       pass
 
-    @remote.remote(Request, Response)
+    @remote.method(Request, Response)
     def remote_method(request):
       pass
 
     expected = descriptor.MethodDescriptor()
     expected.name = 'remote_method'
-    expected.request_type = '__main__.Request'
-    expected.response_type = '__main__.Response'
+    expected.request_type = 'descriptor_test.Request'
+    expected.response_type = 'descriptor_test.Response'
 
     described = descriptor.describe_method(remote_method)
     described.check_initialized()
 
     class MyService(remote.Service):
 
-      @remote.remote(Request1, Response1)
+      @remote.method(Request1, Response1)
       def method1(self, request):
         pass
 
-      @remote.remote(Request2, Response2)
+      @remote.method(Request2, Response2)
       def method2(self, request):
         pass
 
 
     class Service(remote.Service):
 
-      @remote.remote(Param, Param)
+      @remote.method(Param, Param)
       def fn(self):
         return Param()
 

File python/protorpc/dynamic_test.py

File contents unchanged.

File python/protorpc/forms_test.py

File contents unchanged.

File python/protorpc/generate_proto_test.py

File contents unchanged.

File python/protorpc/generate_python.py

   """
   for method in method_descriptors:
     out << ''
-    out << "@remote.remote('%s', '%s')" % (method.request_type,
+    out << "@remote.method('%s', '%s')" % (method.request_type,
                                            method.response_type)
     out << 'def %s(self, request):' % (method.name,)
     with out.indent():
 
     class MyService(remote.Service):
 
-      @remote.remote('my_package.MyRequestType', 'my_package.MyResponseType')
+      @remote.method('my_package.MyRequestType', 'my_package.MyResponseType')
       def my_method(self, request):
         raise NotImplementedError('Method my_method is not implemented')
 

File python/protorpc/generate_python_test.py

File contents unchanged.

File python/protorpc/generate_test.py

File contents unchanged.

File python/protorpc/messages_test.py

     class MyMessage(messages.Message):
       pass
 
-    self.assertEquals('__main__.MyMessage', MyMessage.definition_name())
+    self.assertEquals('messages_test.MyMessage', MyMessage.definition_name())
     self.assertEquals(unicode, type(MyMessage.definition_name()))
 
   def testDefinitionName_OverrideModule(self):
 
           pass
 
-    self.assertEquals('__main__.MyMessage.NestedMessage',
+    self.assertEquals('messages_test.MyMessage.NestedMessage',
                       MyMessage.NestedMessage.definition_name())
-    self.assertEquals('__main__.MyMessage.NestedMessage.NestedMessage',
+    self.assertEquals('messages_test.MyMessage.NestedMessage.NestedMessage',
                       MyMessage.NestedMessage.NestedMessage.definition_name())
 
 

File python/protorpc/protobuf_test.py

File contents unchanged.

File python/protorpc/protojson_test.py

File contents unchanged.

File python/protorpc/protourlencode_test.py

File contents unchanged.

File python/protorpc/registry.py

     """Get service registry associated with this service instance."""
     return self.__registry
 
-  @remote.remote(message_types.VoidMessage, ServicesResponse)
+  @remote.method(message_types.VoidMessage, ServicesResponse)
   def services(self, request):
     """Get all registered services."""
     response = ServicesResponse()
 
     return response
 
-  @remote.remote(GetFileSetRequest, GetFileSetResponse)
+  @remote.method(GetFileSetRequest, GetFileSetResponse)
   def get_file_set(self, request):
     """Get file-set for registered servies."""
     response = GetFileSetResponse()

File python/protorpc/registry_test.py

 class MyService1(remote.Service):
   """Test service that refers to messages in another module."""
 
-  @remote.remote(test_util.NestedMessage, test_util.NestedMessage)
+  @remote.method(test_util.NestedMessage, test_util.NestedMessage)
   def a_method(self, request):
     pass
                  

File python/protorpc/remote.py

     # and response message types.  The remote method itself must take a single
     # parameter which is an instance of RequestMessage and return an instance
     # of ResponseMessage.
-    @remote(RequestMessage, ResponseMessage)
+    @method(RequestMessage, ResponseMessage)
     def remote_method(self, request):
       # Return an instance of ResponseMessage.
 
 
   class MyService(Service):
 
-    @remote(DoSomethingRequest, DoSomethingResponse)
+    @method(DoSomethingRequest, DoSomethingResponse)
     def do_something(self, request):
       ... implement do-something ...
 
   class MyBetterService(Service):
 
-    @remote(DoSomethingRequest, DoSomethingResponse)
+    @method(DoSomethingRequest, DoSomethingResponse)
     def do_something(self, request):
       response = super(MyService, self).do_something.remote.method(request)
       ... do something with response ...
 
 __author__ = 'rafek@google.com (Rafe Kaplan)'
 
+import logging
 import sys
 
 from protorpc import message_types
     'StubBase',
     'RequestState',
     'get_remote_method_info',
-    'remote',
+    'method',
 ]
 
 
     Args:
       method: The method which implements the remote method.  This is a
         function that will act as an instance method of a class definition
-        that is decorated by '@remote'.  It must always take 'self' as its
+        that is decorated by '@method'.  It must always take 'self' as its
         first parameter.
       request_type: Expected request type for the remote method.
       response_type: Expected response type for the remote method.
     return self.__response_type
 
 
-def remote(request_type, response_type):
+def method(request_type, response_type):
   """Method decorator for creating remote methods.
 
   Args:
     TypeError: if the request_type or response_type parameters are not
       proper subclasses of messages.Message.
   """
-
   if (not isinstance(request_type, basestring) and
       (not isinstance(request_type, type) or
        not issubclass(request_type, messages.Message) or
   return remote_method_wrapper
 
 
+def remote(request_type, response_type):
+  """Temporary backward compatibility alias for method."""
+  logging.warning('The remote decorator has been renamed method.  It will be '
+                  'removed in very soon from future versions of ProtoRPC.')
+  return method(request_type, response_type)
+
+
 def get_remote_method_info(method):
   """Get remote method info object from remote method.
 
 
     class AccountService(remote.Service):
 
-      @remote.remote(NewContact, message_types.VoidMessage):
+      @remote.method(NewContact, message_types.VoidMessage):
       def new_contact(self, request):
         ... implementation ...
 
               (attribute, name))
 
           base_remote_method_info = get_remote_method_info(base_method)
-          remote_decorator = remote(
+          remote_decorator = method(
             base_remote_method_info.request_type,
             base_remote_method_info.response_type)
           new_remote_method = remote_decorator(value)

File python/protorpc/remote_test.py

 
 class MyService(remote.Service):
 
-  @remote.remote(Request, Response)
+  @remote.method(Request, Response)
   def remote_method(self, request):
     response = Response()
     response.value = request.value
   def __init__(self):
     self.request_ids = []
 
-  @remote.remote(SimpleRequest, SimpleResponse)
+  @remote.method(SimpleRequest, SimpleResponse)
   def remote_method(self, request):
     self.request_ids.append(id(request))
     return SimpleResponse()
     """Test use of remote decorator to resolve message types by name."""
     class OtherService(remote.Service):
 
-      @remote.remote('SimpleRequest', 'SimpleResponse')
+      @remote.method('SimpleRequest', 'SimpleResponse')
       def remote_method(self, request):
         pass
 
     """Test failure to find message types."""
     class OtherService(remote.Service):
 
-      @remote.remote('NoSuchRequest', 'NoSuchResponse')
+      @remote.method('NoSuchRequest', 'NoSuchResponse')
       def remote_method(self, request):
         pass
 
 
     class AnotherService(object):
 
-      @remote.remote(SimpleRequest, SimpleResponse)
+      @remote.method(SimpleRequest, SimpleResponse)
       def remote_method(self, unused_request):
         return self.return_this
 
       def declare():
         class BadService(object):
 
-          @remote.remote(request_type, SimpleResponse)
+          @remote.method(request_type, SimpleResponse)
           def remote_method(self, request):
             pass
 
       def declare():
         class BadService(object):
 
-          @remote.remote(SimpleRequest, response_type)
+          @remote.method(SimpleRequest, response_type)
           def remote_method(self, request):
             pass
 
 
     class Service(object):
 
-      @remote.remote(Request, Response)
+      @remote.method(Request, Response)
       def remote_method(self, request):
         pass
 
     """Test all_remote_methods on a sub-class of a service."""
     class SubClass(MyService):
 
-      @remote.remote(Request, Response)
+      @remote.method(Request, Response)
       def sub_class_method(self, request):
         pass
 
     def do_override():
       class SubClass(MyService):
 
-        @remote.remote(Request, Response)
+        @remote.method(Request, Response)
         def remote_method(self, request):
           pass
 

File python/protorpc/service_handlers_test.py

 class Service(object):
   """A simple service that takes a Request1 and returns Request2."""
 
-  @remote.remote(Request1, Response1)
+  @remote.method(Request1, Response1)
   def method1(self, request):
     response = Response1()
     if hasattr(request, 'integer_field'):
       response.enum_field = request.enum_field
     return response
 
-  @remote.remote(RepeatedMessage, RepeatedMessage)
+  @remote.method(RepeatedMessage, RepeatedMessage)
   def repeated_method(self, request):
     response = RepeatedMessage()
     if hasattr(request, 'ints'):
 
       initialize_request_state = self.mox.CreateMockAnything()
 
-      @remote.remote(Request1, Response1)
+      @remote.method(Request1, Response1)
       def method1(self, request):
         return Response1()
 
 
       initialize_request_state = self.mox.CreateMockAnything()
 
-      @remote.remote(Request1, Response1)
+      @remote.method(Request1, Response1)
       def method1(self, request):
         return Response1()
 
   def __init__(self, test):
     self.test = test
 
-  @remote.remote(Request1, Response1)
+  @remote.method(Request1, Response1)
   def my_method(self, request):
     self.test.request = request
     return Response1(string_field='a response')

File python/protorpc/transport_test.py

 
 class Service(remote.Service):
   
-  @remote.remote(Message, Message)
+  @remote.method(Message, Message)
   def method(self, request):
     pass
 
     class MyResponse(messages.Message):
       response_value = messages.StringField(1)
 
-    @remote.remote(MyRequest, MyResponse)
+    @remote.method(MyRequest, MyResponse)
     def mymethod(request):
       self.fail('mymethod should not be directly invoked.')
 

File python/protorpc/util_test.py

File contents unchanged.

File python/setup.py

File contents unchanged.