-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.plim
846 lines (772 loc) · 23.6 KB
/
index.plim
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
-namespace module="utils.formatters" name="formatters" inheritable="True"
doctype 5
html lang="en"
head
title Use Pyramid Like a Pro
meta charset="utf-8"
meta name="viewport" content="width=792, user-scalable=no"
meta http-equiv="x-ua-compatible" content="ie=edge"
link rel="stylesheet" href="theme/styles/screen.css"
link rel="stylesheet" href="pygment_style.css"
/*link rel="stylesheet" href="pastie.css"*/
link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"
link rel="shortcut icon" href="pylons.ico"
-scss
/*$pylons_color: #f89929;*/
$pylons_color: #f8c836;
$pylons_blue: #124a7e;
$pylons_red: #e00100;
$grey: #2A2B2D;
@font-face {
font-family: 'Love Ya Like A Sister', cursive;
src: url('fonts/LoveYaLikeASister.ttf') format('truetype');
}
@font-face {
font-family: 'Ubuntu Mono';
src: url('fonts/UbuntuMono-R.ttf') format('truetype');
}
@font-face {
font-family: 'Ubuntu';
src: url('fonts/Ubuntu-R.ttf') format('truetype');
}
mark {
padding-left: 8px;
padding-right: 8px;
border-radius: 6px;
color: #f00;
}
.red { color: $pylons_red; }
.blue { color: $pylons_blue; }
.list {
background:#3f4144 url(pictures/linen.png);
@include retina {
background-image:url(pictures/linen@2x.png);
background-size: 256px;
}
a {
border-bottom:0.1em solid;
color: $pylons_blue;
}
.slide {
&:after {
font-family: 'Love Ya Like A Sister', cursive;
color: darken($pylons_color, 30%);
text-shadow: 2px 2px #000;
}
// Current
&:target {
&:before {
box-shadow:
0 0 0 1px darken($pylons_color, 10%),
0 0 0 10px $pylons_color,
0 20px 50px rgba($grey, 0.6);
@media (max-width:$break) {
box-shadow:
0 0 0 1px darken($pylons_color, 10%),
0 0 0 10px $pylons_color,
0 20px 50px rgba($grey, 0.6);
}
}
&:after {
text-shadow:0 1px 1px rgba($grey, 0.6);
color:$pylons_color;
}
}
}
}
img.photo_border {
box-shadow:
0px 0px 0px 2px rgba(0,0,0,0.6),
0px 0px 0px 14px #fff,
0px 0px 0px 18px rgba(0,0,0,0.1),
6px 6px 8px 17px #555;
}
.caption h1 {
color: $pylons_color;
text-shadow: 6px 6px #000;
}
.caption {
color: $pylons_color;
text-shadow: 3px 3px #000;
}
.badge a {
background: none;
}
.text-center {
text-align:center;
}
.slide a {
color: $pylons_blue;
border-bottom: none;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.smaller-font {
font-size: smaller;
}
.white-text {
color:#FFF;
}
.comment {
color: rgb(153, 153, 153);
}
.slide#Cover {
border-top: none;
h2 {
font-family: 'Ubuntu', sans-serif;
margin:30px 0 0;
color:#FFF;
text-shadow: 3px 3px #000;
font-size: 2em;
.a {
color:#F33;
}
}
p {
font-family: 'Ubuntu', sans-serif;
margin: 0 0 0;
font-size: 1.25em;
a {
color:#FFF;
&:hover {
color: #FF3;
}
}
.social {
font-size: 3em;
}
&.author {
font-size: 1.1em;
text-shadow: 2px 2px #000;
margin:10px 0 0;
font-style:italic;
}
}
}
.slide {
border-top: 6px solid $pylons_color;
p {
/*font-size: 110%;*/
&.note {
color: $pylons_red;
}
}
blockquote p {
font-size: 2em;
}
h2 {
img {
vertical-align: text-top;
}
color: lighten($pylons_blue, 10%);
}
}
.slide.shout h2 {
padding-bottom: 30px;
mark {
margin-top 16px;
}
}
h2 mark.mark {
line-height: 1.4;
padding-left: 80px;
padding-right: 80px;
}
.slide li {
2.2em;
}
.Picture h2 {
color: #FFF;
}
#SeeMore {
h2 {
font-size: 6.25em;
}
img {
width:0.72em;
height:0.72em;
}
font-style: normal;
}
.shout {
&.medium {
h2 {
font-size: 7.5em;
}
}
&.small {
h2 {
font-size: 5.625em;
}
}
&.x-small {
h2 {
font-size: 4em;
mark {
line-height: 1.4;
}
}
}
}
/* font-awesome fix on shower */
.slide i.icon {
text-indent: 0;
font-style: normal;
&.alien {
color: #999;
}
}
/* pygments style */
.linenodiv {
margin-right: 0.6em;
}
.slide pre code {
font-size: 1.2em;
font-family: 'Ubuntu Mono', sans-serif;
&.bigger {
font-size: 1.3em;
}
}
body.list
header.caption
h1 Use Pyramid Like a Pro
p Keith Yang
section#Cover.slide.cover: div
h2 Use Pyramid
h2 Like
,
span.a
, a
Pro
p.author
a href="http://quest.keitheis.org" Keith Yang
p
span.white-text
, @keitheis
/ p
span.social.next
i.icon.icon-twitter.icon-light
i.icon.icon-linkedin.icon-light
i.icon.icon-google-plus.icon-light
i.icon.icon-facebook.icon-light
i.icon.icon-github.icon-light
img (src="pictures/pyramid-aliens2-1920X1200.jpg"
width="100%"
title="Pyramid Aliens Picture by Felix LaFlamme"
alt="Pyramid Aliens Picture by Felix LaFlamme")
<!-- Designed and done by Felix LaFlamme, http://www.felixlaflamme.com/ -->
section.slide: div
h2
span.red.pull-right @keitheis
Keith Yang
ul
li, architect.py in
a href="http://www.biideal.com/"
img src="pictures/biideal_logo.png" alt="biideal logo" title="biideal"
li, Organizer/Coordinator in
a href="http://taipei.python.org.tw/"
img src="pictures/taipei.py.logo.png" alt="Taipei.py Logo" title="Taipei.py"
li, Web Lead in
a href="http://tw.pycon.org/2013/"
| PyCon Taiwan 2013
section.slide: div
.pull-right
a href="http://www.biideal.com/"
img src="pictures/biideal_logo.png" alt="biideal logo" title="biideal"
h2 Some fun fact
ul
li New EC Startup
,
i.red.icon.icon-shopping-cart
li.next
i.red.icon.icon-rotate-right
,
Re-built on Nov.2012,
,
Apr. 2013 online
li.next Agile style
,
i.red.icon.icon-magic
li.next Powered by
,
img src="pylons.ico" alt=""
,
Pyramid
section.slide: div
.pull-right
a href="http://taipei.python.org.tw/"
img src="pictures/taipei.py.logo.png" alt="Taipei.py Logo" title="Taipei.py"
h2 Taipei.py
ul
li Monthly Meetup
li.next to Weekly Meetup
p.note.next
Taipei.py 的奇幻漂流
section.slide.shout: div
h2
a href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html"
img src="pictures/pyramid-logo.png" alt="Pyramid Official"
br Core
section.slide.shout.medium: div
h2
Choice
,
i.icon.icon-hand-left
br
span.next
Like
br
span.next
Human Being
section.slide: div
h2 Being What?
,
span.next Alien?
,
i.alien.icon.icon-github
ol
li Know your future
li Know your scale
li Know your tool sets
li Know your team, goal, and time frames
p.note.next from future import everything
section.slide: div
h2 Choose
,
span.next What?
,
i.icon.icon-hand-left.icon-spin
ol
li
code Web Framework(s)
li
-for name in ['SQL', 'NoSQL', 'ORM', 'Query Helper', 'ALL REDIS?']
code = name
li
code Message Queues
,
, and/or
code Background Workers
li
-for name in ['Template', 'Session', 'API?', 'RESTful', 'RESTlike']
code = name
p.note.next Too many to choose but usually or eventually you have to
section.slide.shout.medium: div
h2 Architecture,
br Architecture,
br Architecture.
section.slide.shout: div
h2
That's why
br
mark.mark.next
Flexibility
br
Counts
section.slide: div
h2, The Power of Pyramid
| (
a href="http://www.pylonsproject.org/"
Pylons Project
| )
ol
li, Flexibility: from minimal to full stack
span.next <code>seriously ready</code>
li
a href="http://www.slideshare.net/rachbelaid/pyramid-views-20820325" title="Pyramid views"
Views config & varies routes
li
a href="http://docs.pylonsproject.org/en/latest/docs/pyramid.html#pyramid-add-on-documentation"
Add-ons and friends
li, Reliability, Agilibility, Simplicity and <code>Community</code>
li.next <code>Fun</code> to learn
section.slide.shout.small: div
h2 Python 3
br Ready
br from Pyramid 1.3
section.slide: div
h2, What Pyramid is
<mark>NOT</mark>
p
Not the first web framework
br you should learn together with
br your first programming language (e.g. Python).
section.slide: div
h2 Rumors
p
i “Use NoSQL and you will be good with schema free.”
p Imagine a type free programming language,
br, which
code
| int(“0”) + str(1)
,
, will be so fine.
section.slide: div
h2 Rumors (cont.)
p
i “Why you should use this web framework”
p Said, Django, Flask, Web2py, Bottle, Rails, ...
br, all the excellent choices.
p.note.next
Also known as「不要欺騙小孩子」
,
i.icon.icon-hand-up
br
span.next.comment.smaller-font
課本上有寫「政黨體質的健全、民主、清廉與執政能力關係人民的幸福」
section.slide.shout: div
h2 I say:
br
“Just use Python”
img.pull-right src="pictures/pythocat.png" width="28%" alt="pythocat icon on github"
p.note.next
i.icon.icon-remove
,
不解釋。
section.slide: div
h2 Fundamental Pyramid School
p
ul
li Understand Pyramid Request
li Separated logic of views, data and business
p.note.next
For any MVC-like Framework
br
M or C is not for business logic
section.slide: div
h2 Fundamental Pyramid School (cont.)
ul
li Super powerful Views
li Flexible Routes
li Context driven
section.slide: div
h2 Database: to SQL
ul
li Postgres, professional or enthusiastic
li MariaDB, new MySQL candidates, or lazy at first
li SQLite for development, personal app, or no production-level needed
section.slide: div
h2 Database: to NoSQL
ul
li To name a few:
ul
li MongoDB, Riak, Cassandra, Redis, Hadoop, ...
li, When you arrived here you'll learn these class.
br Before that, just keep calm on them.
section.slide: div
h2 Database: None
h2
mark.next
Perfect
p.note
No default binding ORM, no bother.
section.slide: div
h2 To ORM
ul
li SQLAlchemy ORM
li, Read
a href="http://doc.ponyorm.com/#what-is-pony-orm"
What is Pony ORM?¶
li Django ORM (not really a choice here)
img.pull-right src="pictures/mango_fotor.jpg" alt="" title="台灣愛文芒果"
li
a href="http://peewee.readthedocs.org/"
Peewee
,
Django ORM like
li
MongoEngine, MongoKit, Ming, ...
p.note.pull-right.next
Have you tried Taiwan Mango?
section.slide: div
h2 Not to ORM
ul
li SQLAlchemy Core
li
a href="http://mosql.mosky.tw/"
, MoSQL
, v0.2 by
a href="http://mosky.tw/" mosky
, , also on
a href="https://github.com/moskytw/mosql"
i.icon.icon-github
,
span.next
| (yesterday v0.1.6)
li Pure SQL Dialects: hard code driver Query
br
| (sqlite3, psycopg2, mysql-python, ...)
li Pure NoSQL Dialects
section.slide: div
h2 Templates: Mako or Jinja2
ul
li Mako - pythonic
span.next
|, or not, depending on you with its nature
br by Mike Bayer (author of Alembic)
li Jinja2
br, by
a href="http://lucumr.pocoo.org/"
Armin Ronacher
| , also Flask author
ol
li Elegant
li Strict, more or less, magic
section.slide: div
h2 Templates (cont.) - Plim
ol
li, by Maxim Avanov
a href="https://github.com/2nd"
i.alien.icon.icon-github
li Ported from Slim template
li Clean HTML usage
li Built on Mako
li
code Fun
span.next and half hell on debug mode
p.note
, Guess what?
span.next
, You'll learn how to guess by using it
i.icon.icon-meh
section.slide: div
h2 Templates (cont.) - Plim
== formatters.code('python', """
-for row in ['apple', 'banana', 'pineapple']
tr
-for col in ['juice', 'muffin', 'pie']
td ${row.capitalize()} ${col}""")
p.note.next
-text filter="h"
That's all. No </blah blah things>.
section.slide: div
h2 Templates (cont.) - Chameleon
p
ZPT, Kid or Genshi lovers should give it a look
== formatters.code('genshi', """
<tr tal:repeat="row 'apple', 'banana', 'pineapple'">
<td tal:repeat="col 'juice', 'muffin', 'pie'">
${row.capitalize()} ${col}
</td>
</tr>""")
section.slide: div
h2 Too many to introduce (again)
ul
li Celery, Python RQ
li RebbitMQ, ZeroMQ
li Redis, memcached
li Beaker, retools (both by <code>Ben Bangert</code>, Pylons 1 author)
p.note.next
Pylons 2? You got it: Pyramid.
section.slide: div
h2 Oh, Sentry
ul
li, by David Cramer (our Keynote speaker)
li, Awesome error events handle
li, Host by yourself or
a href="https://getsentry.com/"
| getsentry.com
section.slide: div
h2 My better practices
p
ul
li Separate the (DB) models and behaviors.
li.next Reproduce-able development database (Fixtures)
li.next Development mode optimization
li.next
a href="https://github.com/2nd/plim" title="Python port of Ruby's Slim template language built on top of the Mako Templates."
Plim template
p.note
, Double-edged swords
i.icon.icon-cut
,
, use them carefully.
section.slide: div
h2 My better practices (cont.)
p
ul
li Explicit architecture (lib, tasks, schemas ... folders)
br
| with explicit nameing
li.next Focus on a utc module handles datetime & timezone
li.next Fundamental doc: README and doc/**/*.rst
li.next Avoid mess sys or deploy stuff in code repository
br if possible
section.slide.shout: div
h2, Minimal Viable
span.red Code
,
i.icon.icon-code.smaller
section.slide: div
h2 My worser lesson 1
== formatters.code('python', """
def ugly_customized_routes(config, resource_route,
path=None,
actions="ICRUD",
resource_name=None):
...""")
p.note
Not aesthetic route helper
section.slide: div
h2 My worser lesson 2
== formatters.code('python', """
print("This is too embarrassing to print")""")
p.note
, Lacking CI tests
i.icon.icon-meh title="meh!"
section.slide: div
h2 Debug mode
.smaller-font
== formatters.code('python', """
if debug_notfound_route:
from .views.notfound import (
NotFoundDebugView as NotFoundView
)
else:
from .views.notfound import NotFoundView
config.add_notfound_view(NotFoundView)""")
/ section.Picture.slide.cover: div
h2
mark
Debug mode (cont.)
a style="background-color:black; filter:alpha(opacity=100); display:block; opacity:1; width:100%"
img style="opacity:0.77; filter:alpha(opacity=77);" src="pictures/debug_screen.png" width="100%" alt=""
section.slide.cover: div
img src="pictures/debugtoolbar.png" width="100%" alt="Debugtoolbar"
section.slide: div
h2 SQL Master
img.photo_border src="pictures/debug_sql.png" width="100%" alt="SQL on Debugtoolbar"
section.slide: div
h2 Logging in the flow
img.photo_border src="pictures/debug_log.png" width="100%" alt="Logging on Debugtoolbar"
section.slide
div
h2 Debug Debugtoolbar
== formatters.code('python', """
# Disable development performance killer
debugtoolbar.panels =
pyramid_debugtoolbar.panels.sqla.SQLADebugPanel
...
#pyramid_debugtoolbar.panels.introspection.IntrospectionDebugPanel
#pyramid_debugtoolbar.panels.tweens.TweensDebugPanel
#pyramid_debugtoolbar.panels.routes.RoutesDebugPanel""")
section.slide: div
h2, Before your first
mark
| release
p
span.icon-stack
i.icon.blue.icon-sign-blank.icon-stack-base
i.icon.icon-terminal.icon-light
,
Practice
ul
li Pshell (the force on production, use it carefully)
li Play Pyramid scripts
li Alembic Database Migration scripts (if using SQLAlchemy)
section.slide.shout.medium: div
h2, Save
i.red.icon.icon-ambulance
br Your Self
br In Time
section.slide: div
h2 Feel the power of Alembic
ul
li, by
a href="http://techspot.zzzeek.org/"
Mike Bayer (author of SQLAlchemy)
li Use op and sa instead your defined Models
== formatters.code('python', """
from alembic import op
import sqlalchemy as sa""")
p.note.next
Because YMWV (Your model WILL vary) between revisions.
section.slide.shout.x-small: div
h2
, alembic -c dev.ini
br
, revision
mark
| --autogenerate
br
, -m "magic hour"
section.slide: div
h2 Encourage Refactor and Clean Code
ul
li.next Feature development helps some.
li.next Clean code, testing and refactor helps
,
mark
| everyone.
section.slide
div
h2 From Web app to API
ul
li Reusable permission control
li Customized API render (extra work on JSON response)
== formatters.code('python', """
@view_defaults(renderer='api', permission='account')
class APIResourceView(APIBaseView, APIPagingMixin):
...""")
section.slide: div
h2 From Web app to API (cont.)
ul
li Views for API Forbidden and NotFound
== formatters.code('python', """
config.add_forbidden_view(
APIForbiddenView, path_info='/api/')
config.add_notfound_view(
APINotFoundView, path_info='/api/')""")
p.note
| (no months or years needed for working)
section.slide: div
h2 API V2 Routes Ready
== formatters.code('python', """
from .api.routes import api_routes
config.include(api_routes, '/api/v1')""")
== formatters.code('python', """
from .api.v1.routes import api_routes as api_v1_routes
config.include(api_v1_routes, '/api/v1')
from .api.routes import api_routes as api_v2_routes
config.include(api_v2_routes, '/api/v2')""")
section.slide: div
figure
blockquote
h2 哭吧你
figcaption 現在每個人可獲得1 Pyramid。
hr
p.text-center 更彈性。
span.comment 要怎樣就怎樣。
br 更多元。
span.comment 做不完的決定。
br 更多頁。
span.comment 為什麼不立即開始讀讀不完的文件呢?
p.next
span.comment.pull-right # flickr 梗
section#more_on_pylons.slide: div
h2 Much More
p
a href="http://www.pylonsproject.org"
img src="pictures/pylons-logo.png" alt="Pylons Project"
br
i.icon.icon-twitter
,
| @pylons
section#thank_you.slide.shout: div
.pull-right
img src="pictures/pycontw2013-logo.png" alt="PyCon Taiwan 2013"
h2
br
br, Thank You
i.red.icon.icon-thumbs-up
p class="badge"
a href="https://github.com/keitheis/use-pyramid-like-a-pro" Fork me on Github
<!-- To hide progress bar from entire presentation just remove "progress" element. -->
.progress
div
script src="shower/shower.min.js"
script
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')
<!-- Copyright © 2013 Keih Yang, keitheis.org -->