예제 #1
0
  def DoMappingTest(self,
                    services,
                    registry_path='/myreg',
                    expected_paths=None):
    mapped_services = mapping = service_handlers.service_mapping(services,
                                                                 registry_path)
    if registry_path:
      form_mapping = mapping[:2]
      mapped_registry_path, mapped_registry_factory = mapping[-1]
      mapped_services = mapping[2:-1]
      self.CheckFormMappings(form_mapping, registry_path=registry_path)

      self.assertEquals(r'(%s)%s' % (registry_path,
                                     service_handlers._METHOD_PATTERN),
                        mapped_registry_path)
      self.assertEquals(registry.RegistryService,
                        mapped_registry_factory.service_factory.service_class)

      # Verify registry knows about other services.
      expected_registry = {registry_path: registry.RegistryService}
      for path, factory in dict(services).iteritems():
        if isinstance(factory, type) and issubclass(factory, remote.Service):
          expected_registry[path] = factory
        else:
          expected_registry[path] = factory.service_class
      self.assertEquals(expected_registry,
                        mapped_registry_factory().service.registry)

    # Verify that services are mapped to URL.
    self.assertEquals(len(services), len(mapped_services))
    for path, service in dict(services).iteritems():
      mapped_path = r'(%s)%s' %  (path, service_handlers._METHOD_PATTERN)
      mapped_factory = dict(mapped_services)[mapped_path]
      self.assertEquals(service, mapped_factory.service_factory)
예제 #2
0
  def testDefaultMappingWithFactory(self):
    mapping = service_handlers.service_mapping(
      [MyService.new_factory('service1')])
    mapped_services = mapping[2:-1]
    self.assertEquals(1, len(mapped_services))
    path, factory = mapped_services[0]

    self.assertEquals(
      r'(/test_package/MyService)' + service_handlers._METHOD_PATTERN,
      path)
    self.assertEquals(MyService, factory.service_factory.service_class)
예제 #3
0
파일: routes.py 프로젝트: alimills/stacks
def main():

  application = webapp.WSGIApplication(
    service_handlers.service_mapping([
      ('/api/observations', observations.Service),
    ]) +
    [
      ('/tasks/fetch_observations', observation_fetcher.Handler),
      ('/', app.Handler)
    ],
    debug=True)

  run_wsgi_app(application)
예제 #4
0
파일: main.py 프로젝트: duca/gridengine
def main():
    #application = webapp.WSGIApplication([('/', MainHandler)],
    #                                    debug=True)
    #util.run_wsgi_app(application)

    m = service_handlers.service_mapping([
        ('/tick', postservice.ReceiveTick),
    ])

    application = webapp.WSGIApplication(m,
                                         ([('/guestbook', guestbook.MainPage),
                                           ('/sign', guestbook.Guestbook)]))
    util.run_wsgi_app(application)
예제 #5
0
  def testDefaultMappingWithClass(self):
    """Test setting path just from the class.

    Path of the mapping will be the fully qualified ProtoRPC service name with
    '.' replaced with '/'.  For example:

      com.nowhere.service.TheService -> /com/nowhere/service/TheService
    """
    mapping = service_handlers.service_mapping([MyService])
    mapped_services = mapping[2:-1]
    self.assertEquals(1, len(mapped_services))
    path, factory = mapped_services[0]

    self.assertEquals(
      r'(/test_package/MyService)' + service_handlers._METHOD_PATTERN,
      path)
    self.assertEquals(MyService, factory.service_factory)
예제 #6
0
        if(tRequest.BlackListType == 'PA'):
            tCustomerHandler.PaBlacklistCustomer(tRequest.Customer)
            #logging.debug("Blacklisted PA")
            return BlacklistResponse(Response = "PA Blacklisted!")
        elif(tRequest.BlackListType == 'Global'):
            tCustomerHandler.GlobalBlacklistCustomer(tRequest.Customer)
            #logging.debug("Blacklisted Global")
            return BlacklistResponse(Response = "Global Blacklisted!")
        else:
            #logging.debug("Error Blacklisting")
            return BlacklistResponse(Response = "Error Blacklisting")
    
    

service_mappings = service_handlers.service_mapping(
    [('/orderajax', OrderAjax),
     ('/blacklist', BlacklistAjax)
    ])

application = webapp.WSGIApplication(service_mappings, debug=True)

def main():
    #util.run_wsgi_app(application)
    service_handlers.run_services(service_mappings)

if __name__ == '__main__':
    main()