-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfobliki.py
53 lines (46 loc) · 1.34 KB
/
fobliki.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from google.appengine.ext import db
from google.appengine.api import users
from vendor import web
from models import *
urls = (
'/login', 'login',
'/logout', 'logout',
'(.*)', 'page'
)
render = web.template.render('templates', base='base')
class logout:
def GET(self):
return web.seeother(users.create_logout_url('/'))
class login:
def GET(self):
return web.seeother(users.create_login_url('/'))
class page:
def GET(self, slug):
key = db.Key.from_path('Page', slug)
page = Page.get(key)
if users.is_current_user_admin():
if page:
if web.ctx.query == '':
return render.show(page, slug)
else:
page = Page()
return render.edit(page, slug)
else:
if page:
return render.show(page, slug)
return render.missing(slug)
def POST(self, slug):
if not users.is_current_user_admin():
return web.seeother('/')
key = db.Key.from_path('Page', slug)
page = Page.get(key)
if page == None:
page = Page(key_name=slug)
i = web.input()
page.slug = slug
page.title = i.title
page.body = i.body
page.put()
return web.seeother(slug)
app = web.application(urls, globals())
main = app.cgirun()