Exemple #1
0
  def __init__(self, request, response, services=None,
               content_type='text/html; charset=UTF-8'):
    """Load and parse the template, saving it for later use."""
    super(Servlet, self).__init__(request, response)
    if self._PAGE_TEMPLATE:  # specified in subclasses
      template_path = self._TEMPLATE_PATH + self._PAGE_TEMPLATE
      self.template = template_helpers.GetTemplate(
          template_path, eliminate_blank_lines=self._ELIMINATE_BLANK_LINES)
    else:
      self.template = None

    self._missing_permissions_template = template_helpers.MonorailTemplate(
        self._TEMPLATE_PATH + self._MISSING_PERMISSIONS_TEMPLATE)
    self.services = services or self.app.config.get('services')
    self.content_type = content_type
    self.mr = None
    self.ratelimiter = ratelimiter.RateLimiter()
Exemple #2
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_user_stub()

        self.mox = mox.Mox()
        self.services = service_manager.Services(
            config=fake.ConfigService(),
            issue=fake.IssueService(),
            user=fake.UserService(),
            project=fake.ProjectService(),
        )
        self.project = self.services.project.TestAddProject('proj',
                                                            project_id=987)

        self.ratelimiter = ratelimiter.RateLimiter()
        ratelimiter.COUNTRY_LIMITS = {}
        os.environ['USER_EMAIL'] = ''
        settings.ratelimiting_enabled = True
        ratelimiter.DEFAULT_LIMIT = 10