Example #1
0
 def start_request(self):
     """
     This is called from the main object publishing loop whenever
     we start processing a new request.  Obviously, this is a good
     place to track the number of requests made.  (If we were
     interested in the number of *successful* requests made, then
     we could override finish_request(), which is called by
     the publisher at the end of each successful request.)
     """
     Session.start_request(self)
     self.num_requests += 1
Example #2
0
 def start_request(self):
     """
     This is called from the main object publishing loop whenever
     we start processing a new request.  Obviously, this is a good
     place to track the number of requests made.  (If we were
     interested in the number of *successful* requests made, then
     we could override finish_request(), which is called by
     the publisher at the end of each successful request.)
     """
     Session.start_request(self)
     self.num_requests += 1
Example #3
0
    def start_request(self, request):
        '''start_request(request : HTTPRequest)

        Called near the beginning of each request: after the HTTPRequest
        object has been built and this Session object has been fetched
        or built, but before we traverse the URL or call the callable
        object found by URL traversal.
        '''
        now = time()
        if now - self.last_access_time > self.timeout_period:
            raise SessionError(session_id=self.id)

        if now - self.last_access_time > self.resolution:
            self.set_last_access_time(now)

        Session.start_request(self, request)
Example #4
0
	def start_request (self):
		Session.start_request(self)

		request = get_request()
		t = time.time()
		request.response.set_charset('utf-8')
		# Determine IP of originator, keep Squid in mind :-)
		try:
			self.ip = request.environ['HTTP_X_FORWARDED_FOR']
		except:
			self.ip = request.environ['REMOTE_ADDR']
		self.port = request.environ['REMOTE_PORT']


		#session = sessions.setdefault(ip,
		#	configlets.Holder(
		#		firstaccess=t,
		#		user=None,
		#		phone='',
		#		language='en',
		#		level=-1,		# Try to auto-login, based on IP
		#	))

		# level==-1 means we should auto-login
		# This works by searching for the first CfgOptUser configlet where
		# the 'pc' variable matches the request originating IP:
		if self.level == -1:
			# Only try auto-login once, so set it to lowest level
			self.level = 0

			users = backend.getConfiglets(name="CfgOptUser")
			if len(users) == 0:
				# be Admin if there are no users configured
				self.user  = "******"
				self.level = 4
				self.language = 'en'
				sys.stderr.write ("[%s] Logging in with user 'programmer' from ip %s, port %s\n" % (time.asctime(time.localtime()), self.ip, self.port))
			else:
				for user in users:
					if user.pc == self.ip:
						self.user = user.name
						self.level = int(user.level)
						self.phone = user.phone
						self.language = user.language
						break
						
		language.setLanguage(self.language)				
Example #5
0
 def start_request(self):
     Session.start_request(self)