Пример #1
0
    def set(self):
        params = {}
        params["key"] = "key"
        params["value"] = "zpy is the law"

        Cookie.set(params["key"], params["value"], 3600)

        return View.load("/cookie/set.tpl", params)
Пример #2
0
Файл: error.py Проект: ZiTAL/zpy
	def __init__(self, status, headers={}, tpl=None):
		
		# get http status code's from json
		hsc = open('config/http_status_codes.json')
		jhsc = json.load(hsc)
		
		# view params
		params = {'key': status, 'value': ''}
		params['SERVER_NAME'] = Env.get('SERVER_NAME')
		params['CONTACT'] = Env.get('CONTACT')
		params['SERVER_SOFTWARE'] = Env.get('SERVER_SOFTWARE')

		# status exists in json
		if status in jhsc:
			params['value'] = jhsc[status]		
		
		# status tpl
		if tpl==None:
			tpl = "error/"+status+".tpl"
		
		# Content type required header
		if 'Content-Type' in headers:
			pass
		else:
			headers['Content-Type'] = 'text/html'
		
		# load view
		data = View.load(tpl, params)
		
		# view not exists, load default tpl
		if data==False:
			tpl = 'error/default.tpl'
			data = View.load(tpl, params)

		msg =	"\nzpy Error: \n"
		msg +=	"Status: "+status+"\n"
		msg +=	"Url: "+Env.get('REQUEST_URI')+"\n"
		msg +=	"Remote Address: "+Env.get('REMOTE_ADDR')+"\n"
		msg +=	"Date: "+time.strftime("%Y/%m/%d %H:%M:%S")+"\n"
		msg +=	"-------------------------------------------"
		
		Log.debug(msg)
		web.HTTPError.__init__(self, status, headers, data)
Пример #3
0
 def destroy(self):
     Cookie.delete("key")
     return View.load("/cookie/destroy.tpl")
Пример #4
0
    def get(self):
        params = {}
        params["key"] = "key"
        params["value"] = Cookie.get("key")

        return View.load("/cookie/get.tpl", params)
Пример #5
0
	def get(self):
		params = {}
		params['key'] = 'count'
		params['value'] = Session.get('count')

		return View.load('/session/get.tpl', params)
Пример #6
0
	def set(self):
		Session.set('count', 1)
		return View.load('/session/set.tpl')
Пример #7
0
	def main(self):
		tpl = View.load('default.tpl', {'title': 'zpy'})
		return tpl