def commitdel(article, req):
	s = DBSession()

	s.delete(article)
	s.commit()

	return HTTPFound(location = req.resource_url(get_root()))
def before_render(event):
	top_links = make_top_links(event.get("request"))
	d = {
		"root": get_root(),
		"url": event.get("request").resource_url,
		"h": helpers,
		"admin": authenticated_userid(event.get("request")),
		"top_links": top_links,
	}

	event.update(d)
def commitedit(context, req):
	s = DBSession()

	if not req.params.get("commit"):
		return HTTPFound(location = req.resource_url(get_root()))

	if req.params.get("new_article"):
		a = Article()
		s.add(a)
	else:
		a = context
	a.title = req.params.get("title", "")
	a.body = req.params.get("body", "")
	s.commit()

	return HTTPFound(location = req.resource_url(a))
示例#4
0
def login(context, req):
	root_url = req.resource_url(get_root(req))
	login_url = req.resource_url(context)

	if "cancel" in req.params:
		return HTTPFound(location = root_url)

	form_username = str(req.params.get('username')).lower()
	form_password = str(req.params.get('password'))

	if form_username != "admin":
		return HTTPFound(location = login_url)
	if "qweqwe" != form_password:
		return HTTPFound(location = login_url)

	headers = remember(req, form_username, max_age = '86400')
	response = HTTPFound(location = root_url)
	response.headerlist.extend(headers)
	return response
示例#5
0
def get_link(req, s):
	s = unicode(s, "utf-8")

	items = map(lambda x: x.strip(), s.split(','))
	url = req.resource_url(get_root()[items[1]], *items[2:])
	return MyLink(items[0], url)
示例#6
0
def logout(context, req):
	headers = forget(req)
	response = HTTPFound(location = req.resource_url(get_root(req)))
	response.headerlist.extend(headers)
	return response