Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 174 lines (124 sloc) 4.497 kB
5afe91f @sj26 edit
sj26 authored
1 ---
2 layout: default
fa71b59 reverting junk
anonymous authored
3 title: Roadmap
5afe91f @sj26 edit
sj26 authored
4 ---
5
fa71b59 reverting junk
anonymous authored
6 # Roadmap
5afe91f @sj26 edit
sj26 authored
7
452598d @sj26 edit
sj26 authored
8 [[discussion](http://groups.google.com/group/webpy/browse_thread/thread/b8505370cef1c37c/9e65f5d621c47913)]
9
0f99092 @irrelative edit
irrelative authored
10 Next release of web.py will be version 0.3. As the number suggests it
5afe91f @sj26 edit
sj26 authored
11 will be major release. There will be some changes to API, which
12 breaks the backward compatability. But I promise, it is not going to
13 change very much.
14
15 Major changes will be
d78fd2c edit
berwyn authored
16
5afe91f @sj26 edit
sj26 authored
17 * return instead of print
18 * moving away from globals
19 * better db api
20
21 Apart from these, the existing subversion repository is be migrated
22 to bazaar.
23 From now on, the official repository will be
24
25 http://webpy.org/bzr/webpy.dev
26
27 Please let me know if you have any suggestions, objections or feature
28 requests.
29 Some of these changes(application stuff and return instead of print)
30 are already checked in, I request you to play with it and let me know
31 if there are any bugs.
32
33 Here is how the new API is going to look like.
34
35 ## Hello world
36
37 `print` will be replaced with `return`.
38
39 import web
40
41 urls = (
42 '/(.*)', 'hello'
43 )
44
45 # more about this later
46 app = web.application(urls, globals())
47
48 class hello:
49 def GET(self, name):
50 if not name: name = 'world'
51 return 'Hello,' + name + '!'
52
53 if __name__ == "__main__":
54 app.run()
55
56 ## database
57
58 db configuration will not be global any more. Multiple databases can
59 be used at the same time and no `web.load()` magic required to make
60 database work.
61
62 import web
63
64 db = web.database(dbn='postgres', db='todo', user='you', pw='')
65
66 db.select('todo')
67 db.select('todo', where='id=$id', vars={'id': 2})
68 db.query('SELECT * FROM todo')
69
70 ## application
71 Application is a new way of mapping urls to classes, coming in 0.3.
72 There will be many different kinds of supported applications.
73
74 ### web.application
75 Application to delegate requests based on path.
76
77 urls = (
78 "/hello", "hello",
79 "/magic/.*", "magic")
80
81 app = web.application(urls, globals())
82
83 ### web.auto_application
84 Application similar to web.application but urls are constructed
85 automatiacally using metaclasses.
86
87 app = web.auto_application()
88
89 class hello(app.page):
90 def GET(self):
91 return "hello, world!"
92
93 ### web.subdir_application
94 Application to delegate requests based on subdir.
0af6999 edit
tommi authored
95 This allows reuse of code easily by taking some existing app and
5afe91f @sj26 edit
sj26 authored
96 mounting it at a directory.
97
98 import wiki
99 import blog
100 import auth
101
102 mapping = (
103 "/wiki", wiki.app,
104 "/blog", blog.app,
105 "/auth", auth.app)
106
107 app = web.subdir_application(mapping)
108
109 ### web.subdomain_application
110 Application to delegate requests based on host.
111 This makes virtual hosting very easy.
112
113 import mainsite
114 import usersite
115
116 mapping = (
117 "(www\.)?example.com", mainsite.app,
118 ".*\.example.com", usersite.app
119 )
120
121 app = web.subdomain_application(mapping)
122
123 ## testing
124
125 Testing becomes very easy with applications. Both doctest and
126 unittest can be used to test web applications.
127
128 doctest:
129
130 urls = ("/hello", "hello")
131 app = web.application(urls, globals())
132
133 class hello:
134 """Hello world example.
135
136 >>> response = app.request("/hello")
137 >>> response.data
138 'hello, world!'
139 >>> response.status
140 '200 OK'
141 >>> response.headers['Content-Type']
142 'text/plain'
143 """
144 def GET(self):
145 web.header('Content-Type', 'text/plain')
146 return "hello, world!"
147
148 unittest:
149
150 import unittest
151 from helloworld import app
152
153 class HelloWorldTest(unittest.TestCase):
154 def testHelloWorld(self):
919d2d7 @tzuryby edit
tzuryby authored
155 response = app.request('GET', '/')
156 self.assertEquals(response.data, 'hello, world!')
157 self.assertEquals(response.headers['Content-Type'], 'text/plain')
158 self.assertEquals(response.status, '200 OK')
5afe91f @sj26 edit
sj26 authored
159
160 if __name__ == "__main__":
161 unittest.main()
162
163 ## templates
164
165 * no whitespace magic
166 * better error reporting
167 * should allow template reuse
168 * Probably use Adam Atlas's implementation
169
170 ## Contrib
171
172 * New module, `web.contrib` with contributed utilities, which are not
173 part of the web.py core. For example, good auth module (port from
ac62fc3 edit
anonymous authored
174 django?) and OpenID support.
Something went wrong with that request. Please try again.