forked from cherokee/CTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.py
51 lines (38 loc) · 1.65 KB
/
test1.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
import CTK
import time
def error(x):
raise Exception("Bad dog!!!!")
def ok(x):
return x.upper()
VALIDATIONS = [
("server!uno", ok),
("server!dos", error),
("server!dos", lambda x: None)
]
URL = "http://www.cherokee-project.com/dynamic/cherokee-list.html"
OPTIONS = [('one','uno'), ('two','dos'), ('three', 'tres')]
def apply():
if CTK.post['server!tri']:
time.sleep(2)
return {'ret': "ok"}
class default:
def __init__ (self):
a = CTK.PropsAuto ('/apply')
a.Add ('To upcase', CTK.TextField({'name': "server!uno"}), 'Converts the content of the field to upcase')
a.Add ('Shows error', CTK.TextField({'name': "server!dos"}), 'It shows an error, it does not matter what you write')
a.Add ('Delay 2secs', CTK.TextField({'name': "server!tri"}), 'It delays response for 2 seconds, so the submitting message is shown')
a.Add ('Active', CTK.Checkbox ({'name': "server!active", 'checked':1}), 'It\'s just a plain checkbox. Nothing to see here')
b = CTK.PropsAuto ('/apply')
b.Add ('Elige', CTK.Combobox ({'name': "server!elec", 'selected': "two"}, OPTIONS), 'la lista')
b.Add ('iPhone', CTK.iPhoneToggle({'name': "server!off"}), 'Fancy')
b.Add ('Carga', CTK.Proxy("www.cherokee-project.com", '/dynamic/cherokee-list.html'), 'Lista')
self.tab = CTK.Tab()
self.tab.Add('Primero', a)
self.tab.Add('Segundo', b)
def __call__ (self):
page = CTK.Page ()
page += self.tab
return page.Render()
CTK.publish ('', default)
CTK.publish ('^/apply$', apply, method='POST', validation=VALIDATIONS)
CTK.run (port=8000)