예제 #1
0
def application(request):
	webnotes.local.request = request
	
	try:
		site = _site or get_site_name(request.host)
		webnotes.init(site=site)
		
		if not webnotes.local.conf:
			# site does not exist
			raise NotFound
		
		webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
			for k, v in (request.form or request.args).iteritems() })
				
		webnotes.local._response = Response()
		webnotes.http_request = webnotes.auth.HTTPRequest()

		if webnotes.local.form_dict.cmd:
			webnotes.handler.handle()
		elif webnotes.request.path.startswith("/api/"):
			webnotes.api.handle()
		elif webnotes.local.request.method in ('GET', 'HEAD'):
			webnotes.webutils.render(webnotes.request.path[1:])
		else:
			raise NotFound

	except HTTPException, e:
		return e
예제 #2
0
		def loader(path):
			import conf
			fail = True
			if hasattr(conf, 'sites_dir'):
				site = get_site_name(self.environ.get('HTTP_HOST'))
				possible_site_path = get_path(directory, path, base=os.path.join(conf.sites_dir, site))
				if os.path.isfile(possible_site_path):
					path = possible_site_path
					fail = False

			if fail and os.path.isfile(get_path(directory, path)):
				path = get_path(directory, path)
				fail = False

			if fail:
				return None, None
			return os.path.basename(path), self._opener(path)
예제 #3
0
		def loader(path):
			import conf
			path = cstr(path)
			fail = True
			if hasattr(conf, 'sites_dir'):
				site = get_site_name(self.environ.get('HTTP_HOST'))
				possible_site_path = get_path(directory, path, base=os.path.join(conf.sites_dir, site))
				if os.path.isfile(possible_site_path):
					path = possible_site_path
					fail = False

			if fail and os.path.isfile(get_path(directory, path)):
				path = get_path(directory, path)
				fail = False

			if fail:
				return None, None
			return os.path.basename(path), self._opener(path)