Commit 90349e30370140922ad8395d86685c1a2fdabbd0
1 parent
1b68268a
Exists in
master
Alterações na view do pyramid_restler
git-svn-id: http://svn.brlight.net/svn/lightbase-neo/trunk/LBBulk@766 29b92fdf-8c97-4584-b987-84e8d3c556fa
Showing
34 changed files
with
710 additions
and
10 deletions
Show diff stats
... | ... | @@ -0,0 +1,35 @@ |
1 | +Metadata-Version: 1.1 | |
2 | +Name: LBBulk | |
3 | +Version: 0.1 | |
4 | +Summary: Translator for external keys to fit properly on the lightbase standard | |
5 | +Home-page: UNKNOWN | |
6 | +Author: Lightbase | |
7 | +Author-email: pedro.ricardo@lightbase.com | |
8 | +License: UNKNOWN | |
9 | +Description: LBBulk README | |
10 | + ================== | |
11 | + | |
12 | + Getting Started | |
13 | + --------------- | |
14 | + | |
15 | + - cd <directory containing this file> | |
16 | + | |
17 | + - $VENV/bin/python setup.py develop | |
18 | + | |
19 | + - $VENV/bin/initialize_LBBulk_db development.ini | |
20 | + | |
21 | + - $VENV/bin/pserve development.ini | |
22 | + | |
23 | + | |
24 | + | |
25 | + 0.0 | |
26 | + --- | |
27 | + | |
28 | + - Initial version | |
29 | + | |
30 | +Keywords: lightbase database translator bulk pyramid | |
31 | +Platform: UNKNOWN | |
32 | +Classifier: Development Status :: 2 - Pre-AlphaFramework :: Pyramid | |
33 | +Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) | |
34 | +Classifier: Natural Language :: EnglishProgramming Language :: Python :: 3 | |
35 | +Classifier: Topic :: Database :: Database Engines/Servers | ... | ... |
... | ... | @@ -0,0 +1,33 @@ |
1 | +CHANGES.txt | |
2 | +MANIFEST.in | |
3 | +README.txt | |
4 | +TODO.txt | |
5 | +development.ini | |
6 | +production.ini | |
7 | +setup.cfg | |
8 | +setup.py | |
9 | +LBBulk.egg-info/PKG-INFO | |
10 | +LBBulk.egg-info/SOURCES.txt | |
11 | +LBBulk.egg-info/dependency_links.txt | |
12 | +LBBulk.egg-info/entry_points.txt | |
13 | +LBBulk.egg-info/not-zip-safe | |
14 | +LBBulk.egg-info/requires.txt | |
15 | +LBBulk.egg-info/top_level.txt | |
16 | +lbbulk/__init__.py | |
17 | +lbbulk/config/__init__.py | |
18 | +lbbulk/config/routing.py | |
19 | +lbbulk/model/Registro.py | |
20 | +lbbulk/model/__init__.py | |
21 | +lbbulk/scripts/__init__.py | |
22 | +lbbulk/scripts/initializedb.py | |
23 | +lbbulk/static/favicon.ico | |
24 | +lbbulk/static/footerbg.png | |
25 | +lbbulk/static/headerbg.png | |
26 | +lbbulk/static/ie6.css | |
27 | +lbbulk/static/middlebg.png | |
28 | +lbbulk/static/pylons.css | |
29 | +lbbulk/static/pyramid-small.png | |
30 | +lbbulk/static/pyramid.png | |
31 | +lbbulk/static/transparent.gif | |
32 | +lbbulk/templates/mytemplate.pt | |
33 | +lbbulk/view/__init__.py | |
0 | 34 | \ No newline at end of file | ... | ... |
No preview for this file type
No preview for this file type
... | ... | @@ -0,0 +1 @@ |
1 | +lbbulk | ... | ... |
TODO.txt
... | ... | @@ -0,0 +1,19 @@ |
1 | +from pyramid.config import Configurator | |
2 | +from sqlalchemy import engine_from_config | |
3 | +from lbbulk.config.routing import make_routes | |
4 | + | |
5 | +from lbbulk.model import Base, metadata, DBSession | |
6 | + | |
7 | + | |
8 | +def main(global_config, **settings): | |
9 | + """ This function returns a Pyramid WSGI application. | |
10 | + """ | |
11 | + config = Configurator(settings=settings) | |
12 | + config.scan('lbbulk') | |
13 | + engine = engine_from_config(settings, 'sqlalchemy.') | |
14 | + DBSession.configure(bind=engine) | |
15 | + Base.metadata.bind = engine | |
16 | + config.include('pyramid_chameleon') | |
17 | + make_routes(config) | |
18 | + config.enable_POST_tunneling() | |
19 | + return config.make_wsgi_app() | |
0 | 20 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +from lbbulk.model.Registo import RegistroContextFactory | |
2 | + | |
3 | +def make_routes(config): | |
4 | + """ | |
5 | + Create routes | |
6 | + """ | |
7 | + config.add_static_view('static', 'static', cache_max_age=3600) | |
8 | + config.add_route('home', '/') | |
9 | + config.add_restful_routes('registo', Registo.RegistroContextFactory) | |
0 | 10 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +from sqlalchemy import Table, Column, Integer, \ | |
2 | + String, join, ForeignKey | |
3 | +from sqlalchemy.orm import column_property | |
4 | +from pyramid_restler.model import SQLAlchemyORMContext | |
5 | +from lbbulk.model import Base, metadata | |
6 | + | |
7 | +# define two Table objects | |
8 | +bulk_sources = Table('lb_bulk_sources', metadata, | |
9 | + Column('id_source', Integer, primary_key=True), | |
10 | + Column('nome_source', String), | |
11 | + ) | |
12 | + | |
13 | +bulk_upload = Table('lb_bulk_upload', metadata, | |
14 | + Column('id_reg', Integer, primary_key=True), | |
15 | + Column('chave_externa', String), | |
16 | + Column('id_source', Integer, ForeignKey('lb_bulk_sources.id_source')) | |
17 | + ) | |
18 | + | |
19 | +# define a join between them. This | |
20 | +# takes place across the bulk_sources.id_source and bulk_upload.id_source | |
21 | +# columns. | |
22 | +registro = join(bulk_sources, bulk_upload) | |
23 | + | |
24 | +# map to it | |
25 | +class Registro(Base): | |
26 | + __table__ = registro | |
27 | + id_source = column_property(bulk_sources.c.id_source, bulk_upload.c.id_source) | |
28 | + | |
29 | +class RegistroContextFactory(SQLAlchemyORMContext): | |
30 | + | |
31 | + entity = Registro | |
32 | + | |
33 | + def session_factory(self): | |
34 | + return Session() | |
35 | + | |
36 | +def root_view(context, request): | |
37 | + registro = Session().query(Registro).all() | |
38 | + return dict(registro=registro, Registro=Registro) | |
0 | 39 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,7 @@ |
1 | +from sqlalchemy import MetaData | |
2 | +from sqlalchemy.ext.declarative import declarative_base | |
3 | +from sqlalchemy.orm import scoped_session, sessionmaker | |
4 | + | |
5 | +metadata = MetaData() | |
6 | +Base = declarative_base() | |
7 | +DBSession = scoped_session(sessionmaker()) | |
0 | 8 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +# package | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +# import os | |
2 | +# import sys | |
3 | +# import transaction | |
4 | + | |
5 | +# from sqlalchemy import engine_from_config | |
6 | + | |
7 | +# from pyramid.paster import ( | |
8 | +# get_appsettings, | |
9 | +# setup_logging, | |
10 | +# ) | |
11 | + | |
12 | +# from pyramid.scripts.common import parse_vars | |
13 | + | |
14 | +# from ..models import ( | |
15 | +# DBSession, | |
16 | +# MyModel, | |
17 | +# Base, | |
18 | +# ) | |
19 | + | |
20 | + | |
21 | +# def usage(argv): | |
22 | +# cmd = os.path.basename(argv[0]) | |
23 | +# print('usage: %s <config_uri> [var=value]\n' | |
24 | +# '(example: "%s development.ini")' % (cmd, cmd)) | |
25 | +# sys.exit(1) | |
26 | + | |
27 | + | |
28 | +# def main(argv=sys.argv): | |
29 | +# if len(argv) < 2: | |
30 | +# usage(argv) | |
31 | +# config_uri = argv[1] | |
32 | +# options = parse_vars(argv[2:]) | |
33 | +# setup_logging(config_uri) | |
34 | +# settings = get_appsettings(config_uri, options=options) | |
35 | +# engine = engine_from_config(settings, 'sqlalchemy.') | |
36 | +# DBSession.configure(bind=engine) | |
37 | +# Base.metadata.create_all(engine) | |
38 | +# with transaction.manager: | |
39 | +# model = MyModel(name='one', value=1) | |
40 | +# DBSession.add(model) | ... | ... |
No preview for this file type
333 Bytes
203 Bytes
... | ... | @@ -0,0 +1,8 @@ |
1 | +* html img, | |
2 | +* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", | |
3 | +this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", | |
4 | +this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), | |
5 | +this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", | |
6 | +this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) | |
7 | +);} | |
8 | +#wrap{display:table;height:100%} | ... | ... |
2.73 KB
... | ... | @@ -0,0 +1,372 @@ |
1 | +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td | |
2 | +{ | |
3 | + margin: 0; | |
4 | + padding: 0; | |
5 | + border: 0; | |
6 | + outline: 0; | |
7 | + font-size: 100%; /* 16px */ | |
8 | + vertical-align: baseline; | |
9 | + background: transparent; | |
10 | +} | |
11 | + | |
12 | +body | |
13 | +{ | |
14 | + line-height: 1; | |
15 | +} | |
16 | + | |
17 | +ol, ul | |
18 | +{ | |
19 | + list-style: none; | |
20 | +} | |
21 | + | |
22 | +blockquote, q | |
23 | +{ | |
24 | + quotes: none; | |
25 | +} | |
26 | + | |
27 | +blockquote:before, blockquote:after, q:before, q:after | |
28 | +{ | |
29 | + content: ''; | |
30 | + content: none; | |
31 | +} | |
32 | + | |
33 | +:focus | |
34 | +{ | |
35 | + outline: 0; | |
36 | +} | |
37 | + | |
38 | +ins | |
39 | +{ | |
40 | + text-decoration: none; | |
41 | +} | |
42 | + | |
43 | +del | |
44 | +{ | |
45 | + text-decoration: line-through; | |
46 | +} | |
47 | + | |
48 | +table | |
49 | +{ | |
50 | + border-collapse: collapse; | |
51 | + border-spacing: 0; | |
52 | +} | |
53 | + | |
54 | +sub | |
55 | +{ | |
56 | + vertical-align: sub; | |
57 | + font-size: smaller; | |
58 | + line-height: normal; | |
59 | +} | |
60 | + | |
61 | +sup | |
62 | +{ | |
63 | + vertical-align: super; | |
64 | + font-size: smaller; | |
65 | + line-height: normal; | |
66 | +} | |
67 | + | |
68 | +ul, menu, dir | |
69 | +{ | |
70 | + display: block; | |
71 | + list-style-type: disc; | |
72 | + margin: 1em 0; | |
73 | + padding-left: 40px; | |
74 | +} | |
75 | + | |
76 | +ol | |
77 | +{ | |
78 | + display: block; | |
79 | + list-style-type: decimal-leading-zero; | |
80 | + margin: 1em 0; | |
81 | + padding-left: 40px; | |
82 | +} | |
83 | + | |
84 | +li | |
85 | +{ | |
86 | + display: list-item; | |
87 | +} | |
88 | + | |
89 | +ul ul, ul ol, ul dir, ul menu, ul dl, ol ul, ol ol, ol dir, ol menu, ol dl, dir ul, dir ol, dir dir, dir menu, dir dl, menu ul, menu ol, menu dir, menu menu, menu dl, dl ul, dl ol, dl dir, dl menu, dl dl | |
90 | +{ | |
91 | + margin-top: 0; | |
92 | + margin-bottom: 0; | |
93 | +} | |
94 | + | |
95 | +ol ul, ul ul, menu ul, dir ul, ol menu, ul menu, menu menu, dir menu, ol dir, ul dir, menu dir, dir dir | |
96 | +{ | |
97 | + list-style-type: circle; | |
98 | +} | |
99 | + | |
100 | +ol ol ul, ol ul ul, ol menu ul, ol dir ul, ol ol menu, ol ul menu, ol menu menu, ol dir menu, ol ol dir, ol ul dir, ol menu dir, ol dir dir, ul ol ul, ul ul ul, ul menu ul, ul dir ul, ul ol menu, ul ul menu, ul menu menu, ul dir menu, ul ol dir, ul ul dir, ul menu dir, ul dir dir, menu ol ul, menu ul ul, menu menu ul, menu dir ul, menu ol menu, menu ul menu, menu menu menu, menu dir menu, menu ol dir, menu ul dir, menu menu dir, menu dir dir, dir ol ul, dir ul ul, dir menu ul, dir dir ul, dir ol menu, dir ul menu, dir menu menu, dir dir menu, dir ol dir, dir ul dir, dir menu dir, dir dir dir | |
101 | +{ | |
102 | + list-style-type: square; | |
103 | +} | |
104 | + | |
105 | +.hidden | |
106 | +{ | |
107 | + display: none; | |
108 | +} | |
109 | + | |
110 | +p | |
111 | +{ | |
112 | + line-height: 1.5em; | |
113 | +} | |
114 | + | |
115 | +h1 | |
116 | +{ | |
117 | + font-size: 1.75em; | |
118 | + line-height: 1.7em; | |
119 | + font-family: helvetica, verdana; | |
120 | +} | |
121 | + | |
122 | +h2 | |
123 | +{ | |
124 | + font-size: 1.5em; | |
125 | + line-height: 1.7em; | |
126 | + font-family: helvetica, verdana; | |
127 | +} | |
128 | + | |
129 | +h3 | |
130 | +{ | |
131 | + font-size: 1.25em; | |
132 | + line-height: 1.7em; | |
133 | + font-family: helvetica, verdana; | |
134 | +} | |
135 | + | |
136 | +h4 | |
137 | +{ | |
138 | + font-size: 1em; | |
139 | + line-height: 1.7em; | |
140 | + font-family: helvetica, verdana; | |
141 | +} | |
142 | + | |
143 | +html, body | |
144 | +{ | |
145 | + width: 100%; | |
146 | + height: 100%; | |
147 | +} | |
148 | + | |
149 | +body | |
150 | +{ | |
151 | + margin: 0; | |
152 | + padding: 0; | |
153 | + background-color: #fff; | |
154 | + position: relative; | |
155 | + font: 16px/24px NobileRegular, "Lucida Grande", Lucida, Verdana, sans-serif; | |
156 | +} | |
157 | + | |
158 | +a | |
159 | +{ | |
160 | + color: #1b61d6; | |
161 | + text-decoration: none; | |
162 | +} | |
163 | + | |
164 | +a:hover | |
165 | +{ | |
166 | + color: #e88f00; | |
167 | + text-decoration: underline; | |
168 | +} | |
169 | + | |
170 | +body h1, body h2, body h3, body h4, body h5, body h6 | |
171 | +{ | |
172 | + font-family: NeutonRegular, "Lucida Grande", Lucida, Verdana, sans-serif; | |
173 | + font-weight: 400; | |
174 | + color: #373839; | |
175 | + font-style: normal; | |
176 | +} | |
177 | + | |
178 | +#wrap | |
179 | +{ | |
180 | + min-height: 100%; | |
181 | +} | |
182 | + | |
183 | +#header, #footer | |
184 | +{ | |
185 | + width: 100%; | |
186 | + color: #fff; | |
187 | + height: 40px; | |
188 | + position: absolute; | |
189 | + text-align: center; | |
190 | + line-height: 40px; | |
191 | + overflow: hidden; | |
192 | + font-size: 12px; | |
193 | + vertical-align: middle; | |
194 | +} | |
195 | + | |
196 | +#header | |
197 | +{ | |
198 | + background: #000; | |
199 | + top: 0; | |
200 | + font-size: 14px; | |
201 | +} | |
202 | + | |
203 | +#footer | |
204 | +{ | |
205 | + bottom: 0; | |
206 | + background: #000 url(footerbg.png) repeat-x 0 top; | |
207 | + position: relative; | |
208 | + margin-top: -40px; | |
209 | + clear: both; | |
210 | +} | |
211 | + | |
212 | +.header, .footer | |
213 | +{ | |
214 | + width: 750px; | |
215 | + margin-right: auto; | |
216 | + margin-left: auto; | |
217 | +} | |
218 | + | |
219 | +.wrapper | |
220 | +{ | |
221 | + width: 100%; | |
222 | +} | |
223 | + | |
224 | +#top, #top-small, #bottom | |
225 | +{ | |
226 | + width: 100%; | |
227 | +} | |
228 | + | |
229 | +#top | |
230 | +{ | |
231 | + color: #000; | |
232 | + height: 230px; | |
233 | + background: #fff url(headerbg.png) repeat-x 0 top; | |
234 | + position: relative; | |
235 | +} | |
236 | + | |
237 | +#top-small | |
238 | +{ | |
239 | + color: #000; | |
240 | + height: 60px; | |
241 | + background: #fff url(headerbg.png) repeat-x 0 top; | |
242 | + position: relative; | |
243 | +} | |
244 | + | |
245 | +#bottom | |
246 | +{ | |
247 | + color: #222; | |
248 | + background-color: #fff; | |
249 | +} | |
250 | + | |
251 | +.top, .top-small, .middle, .bottom | |
252 | +{ | |
253 | + width: 750px; | |
254 | + margin-right: auto; | |
255 | + margin-left: auto; | |
256 | +} | |
257 | + | |
258 | +.top | |
259 | +{ | |
260 | + padding-top: 40px; | |
261 | +} | |
262 | + | |
263 | +.top-small | |
264 | +{ | |
265 | + padding-top: 10px; | |
266 | +} | |
267 | + | |
268 | +#middle | |
269 | +{ | |
270 | + width: 100%; | |
271 | + height: 100px; | |
272 | + background: url(middlebg.png) repeat-x; | |
273 | + border-top: 2px solid #fff; | |
274 | + border-bottom: 2px solid #b2b2b2; | |
275 | +} | |
276 | + | |
277 | +.app-welcome | |
278 | +{ | |
279 | + margin-top: 25px; | |
280 | +} | |
281 | + | |
282 | +.app-name | |
283 | +{ | |
284 | + color: #000; | |
285 | + font-weight: 700; | |
286 | +} | |
287 | + | |
288 | +.bottom | |
289 | +{ | |
290 | + padding-top: 50px; | |
291 | +} | |
292 | + | |
293 | +#left | |
294 | +{ | |
295 | + width: 350px; | |
296 | + float: left; | |
297 | + padding-right: 25px; | |
298 | +} | |
299 | + | |
300 | +#right | |
301 | +{ | |
302 | + width: 350px; | |
303 | + float: right; | |
304 | + padding-left: 25px; | |
305 | +} | |
306 | + | |
307 | +.align-left | |
308 | +{ | |
309 | + text-align: left; | |
310 | +} | |
311 | + | |
312 | +.align-right | |
313 | +{ | |
314 | + text-align: right; | |
315 | +} | |
316 | + | |
317 | +.align-center | |
318 | +{ | |
319 | + text-align: center; | |
320 | +} | |
321 | + | |
322 | +ul.links | |
323 | +{ | |
324 | + margin: 0; | |
325 | + padding: 0; | |
326 | +} | |
327 | + | |
328 | +ul.links li | |
329 | +{ | |
330 | + list-style-type: none; | |
331 | + font-size: 14px; | |
332 | +} | |
333 | + | |
334 | +form | |
335 | +{ | |
336 | + border-style: none; | |
337 | +} | |
338 | + | |
339 | +fieldset | |
340 | +{ | |
341 | + border-style: none; | |
342 | +} | |
343 | + | |
344 | +input | |
345 | +{ | |
346 | + color: #222; | |
347 | + border: 1px solid #ccc; | |
348 | + font-family: sans-serif; | |
349 | + font-size: 12px; | |
350 | + line-height: 16px; | |
351 | +} | |
352 | + | |
353 | +input[type=text], input[type=password] | |
354 | +{ | |
355 | + width: 205px; | |
356 | +} | |
357 | + | |
358 | +input[type=submit] | |
359 | +{ | |
360 | + background-color: #ddd; | |
361 | + font-weight: 700; | |
362 | +} | |
363 | + | |
364 | +/*Opera Fix*/ | |
365 | +body:before | |
366 | +{ | |
367 | + content: ""; | |
368 | + height: 100%; | |
369 | + float: left; | |
370 | + width: 0; | |
371 | + margin-top: -32767px; | |
372 | +} | ... | ... |
6.88 KB
32.3 KB
49 Bytes
... | ... | @@ -0,0 +1,73 @@ |
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> | |
3 | +<head> | |
4 | + <title>The Pyramid Web Framework</title> | |
5 | + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> | |
6 | + <meta name="keywords" content="python web application" /> | |
7 | + <meta name="description" content="pyramid web application" /> | |
8 | + <link rel="shortcut icon" href="${request.static_url('lbbulk:static/favicon.ico')}" /> | |
9 | + <link rel="stylesheet" href="${request.static_url('lbbulk:static/pylons.css')}" type="text/css" media="screen" charset="utf-8" /> | |
10 | + <link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" /> | |
11 | + <link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" /> | |
12 | + <!--[if lte IE 6]> | |
13 | + <link rel="stylesheet" href="${request.static_url('lbbulk:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" /> | |
14 | + <![endif]--> | |
15 | +</head> | |
16 | +<body> | |
17 | + <div id="wrap"> | |
18 | + <div id="top"> | |
19 | + <div class="top align-center"> | |
20 | + <div><img src="${request.static_url('lbbulk:static/pyramid.png')}" width="750" height="169" alt="pyramid"/></div> | |
21 | + </div> | |
22 | + </div> | |
23 | + <div id="middle"> | |
24 | + <div class="middle align-center"> | |
25 | + <p class="app-welcome"> | |
26 | + Welcome to <span class="app-name">${project}</span>, an application generated by<br/> | |
27 | + the Pyramid Web Framework. | |
28 | + </p> | |
29 | + </div> | |
30 | + </div> | |
31 | + <div id="bottom"> | |
32 | + <div class="bottom"> | |
33 | + <div id="left" class="align-right"> | |
34 | + <h2>Search documentation</h2> | |
35 | + <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/search.html"> | |
36 | + <input type="text" id="q" name="q" value="" /> | |
37 | + <input type="submit" id="x" value="Go" /> | |
38 | + </form> | |
39 | + </div> | |
40 | + <div id="right" class="align-left"> | |
41 | + <h2>Pyramid links</h2> | |
42 | + <ul class="links"> | |
43 | + <li> | |
44 | + <a href="http://pylonsproject.org">Pylons Website</a> | |
45 | + </li> | |
46 | + <li> | |
47 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#narrative-documentation">Narrative Documentation</a> | |
48 | + </li> | |
49 | + <li> | |
50 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#reference-material">API Documentation</a> | |
51 | + </li> | |
52 | + <li> | |
53 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#tutorials">Tutorials</a> | |
54 | + </li> | |
55 | + <li> | |
56 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#detailed-change-history">Change History</a> | |
57 | + </li> | |
58 | + <li> | |
59 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#sample-applications">Sample Applications</a> | |
60 | + </li> | |
61 | + <li> | |
62 | + <a href="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/#support-and-development">Support and Development</a> | |
63 | + </li> | |
64 | + <li> | |
65 | + <a href="irc://irc.freenode.net#pyramid">IRC Channel</a> | |
66 | + </li> | |
67 | + </ul> | |
68 | + </div> | |
69 | + </div> | |
70 | + </div> | |
71 | + </div> | |
72 | +</body> | |
73 | +</html> | ... | ... |
No preview for this file type
lbbulk/__init__.py
1 | 1 | from pyramid.config import Configurator |
2 | 2 | from sqlalchemy import engine_from_config |
3 | 3 | from lbbulk.config.routing import make_routes |
4 | +from pyramid_restler import includeme | |
4 | 5 | |
5 | 6 | from lbbulk.model import Base, metadata, DBSession |
6 | 7 | |
... | ... | @@ -13,6 +14,8 @@ def main(global_config, **settings): |
13 | 14 | engine = engine_from_config(settings, 'sqlalchemy.') |
14 | 15 | DBSession.configure(bind=engine) |
15 | 16 | Base.metadata.bind = engine |
17 | + includeme(config) | |
16 | 18 | config.include('pyramid_chameleon') |
17 | 19 | make_routes(config) |
20 | + config.enable_POST_tunneling() | |
18 | 21 | return config.make_wsgi_app() |
19 | 22 | \ No newline at end of file | ... | ... |
lbbulk/config/routing.py
1 | +# import lbbulk.model | |
2 | +from lbbulk.model.Registro import RegistroContextFactory | |
3 | +from lbbulk.view.restfulview import RegCustomView | |
4 | + | |
1 | 5 | def make_routes(config): |
2 | 6 | """ |
3 | 7 | Create routes |
4 | 8 | """ |
5 | 9 | config.add_static_view('static', 'static', cache_max_age=3600) |
6 | - config.add_route('home', '/') | |
7 | 10 | \ No newline at end of file |
11 | + config.add_route('home', '/') | |
12 | + config.add_restful_routes('registro', RegistroContextFactory, view=RegCustomView) | |
8 | 13 | \ No newline at end of file | ... | ... |
lbbulk/model/Registro.py
1 | 1 | from sqlalchemy import Table, Column, Integer, \ |
2 | 2 | String, join, ForeignKey |
3 | 3 | from sqlalchemy.orm import column_property |
4 | -from lbbulk.model import Base, metadata | |
4 | +from pyramid_restler.model import SQLAlchemyORMContext | |
5 | +from lbbulk.model import Base, metadata, session | |
5 | 6 | |
6 | 7 | # define two Table objects |
7 | 8 | bulk_sources = Table('lb_bulk_sources', metadata, |
... | ... | @@ -23,4 +24,11 @@ registro = join(bulk_sources, bulk_upload) |
23 | 24 | # map to it |
24 | 25 | class Registro(Base): |
25 | 26 | __table__ = registro |
26 | - id_source = column_property(bulk_sources.c.id_source, bulk_upload.c.id_source) | |
27 | 27 | \ No newline at end of file |
28 | + id_source = column_property(bulk_sources.c.id_source, bulk_upload.c.id_source) | |
29 | + | |
30 | +class RegistroContextFactory(SQLAlchemyORMContext): | |
31 | + | |
32 | + entity = Registro | |
33 | + | |
34 | + def session_factory(self): | |
35 | + return session | |
28 | 36 | \ No newline at end of file | ... | ... |
lbbulk/model/__init__.py
... | ... | @@ -4,4 +4,5 @@ from sqlalchemy.orm import scoped_session, sessionmaker |
4 | 4 | |
5 | 5 | metadata = MetaData() |
6 | 6 | Base = declarative_base() |
7 | -DBSession = scoped_session(sessionmaker()) | |
8 | 7 | \ No newline at end of file |
8 | +DBSession = scoped_session(sessionmaker()) | |
9 | +session = DBSession | |
9 | 10 | \ No newline at end of file | ... | ... |
lbbulk/templates/mytemplate.pt
... | ... | @@ -31,11 +31,12 @@ |
31 | 31 | <div id="bottom"> |
32 | 32 | <div class="bottom"> |
33 | 33 | <div id="left" class="align-right"> |
34 | - <h2>Search documentation</h2> | |
35 | - <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/search.html"> | |
36 | - <input type="text" id="q" name="q" value="" /> | |
37 | - <input type="submit" id="x" value="Go" /> | |
38 | - </form> | |
34 | + <h2>Restful Views</h2> | |
35 | + <ul class="links"> | |
36 | + <li> | |
37 | + <a href="registro">Registro</a> | |
38 | + </li> | |
39 | + </ul> | |
39 | 40 | </div> |
40 | 41 | <div id="right" class="align-left"> |
41 | 42 | <h2>Pyramid links</h2> | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +from pyramid_restler.view import RESTfulView | |
2 | +import json | |
3 | + | |
4 | +class RegCustomView(RESTfulView): | |
5 | + def get_member(self): | |
6 | + id = self.request.matchdict['id'] | |
7 | + json_reg = self.requests.params['json_reg'] | |
8 | + json_reg = json.loads(json_reg) | |
9 | + ins = users.insert().values(chave_externa=json_reg['id_reg', fullname='Jack Jones') | |
10 | + member = self.context.get_member(id) | |
11 | + return self.render_to_response(member) | |
0 | 12 | \ No newline at end of file | ... | ... |