Más contenido relacionado La actualidad más candente (6) Similar a Alex conrad - Pyramid Tweens (PloneConf 2011) (20) Alex conrad - Pyramid Tweens (PloneConf 2011)3. omg tweens r soooo, like, totally awesome!!!!!!1!
lol
(totally friend me on twtr)
^^
4. They are NOT
pre-teenager girls
(too old for toys, too young for boys)
14. Think of them as decorators
applied to each of your Pyramid views.
16. These are not
Tweens, but actual
@foo
decorators, ok?
@bar
def useless_view(request):
return {}
19. WSGI
Tweens
middleware
Pipelining YES YES
Error catching YES YES
WSGI compliant YES NO
Access to
application NO YES
(registry, template
engine, ...)
23. A tween factory returns a function:
a tween
(just like a decorator does)
35. REQUEST
---------------------- INGRESS ----------------------
------------------------ MAIN ------------------------
36. 3 ways of positioning tweens
- implicit
- implicit (hint)
- explicit
37. 3 ways of positioning tweens
- implicit
- implicit (hint)
- explicit
40. INGRESS
useless.null_tween_factory
useless.useless_tween_factory
pyramid.tweens.excview_tween_factory
MAIN
41. REQUEST
INGRESS
useless.null_tween_factory
useless.useless_tween_factory
pyramid.tweens.excview_tween_factory
MAIN
42. 3 ways of positioning tweens
- implicit
- implicit (hint)
- explicit
46. 3 ways of positioning tweens
- implicit
- implicit (hint)
- explicit
57. Although it can decide whether or not it should
render HTML depending on your host address
62. 1
Register your commit / rollback action with
the transaction package (join() the transaction)
63. 2
pyramid_tm calls:
transaction.begin() on request
then
transaction.commit() or transaction.rollback()
67. Avoid sending an email
“Your account has been created! o/”
when your DB write actually failed
68. Things you could do:
- commit your DB transaction
- invalidate cache
- send an email
...
69. I already have try/except blocks in my Pyramid
views, I don't need pyramid_tm.
Until you get a stupid Exception outside your
block (e.g., in the renderer) for whatever reason.
Also know as: a bug.
71. Did you know?
pyramid_tm is responsible
for the existence of Pyramid tweens.
It was the first use case for tweens.