Permalink
Browse files

Modified the databag option.

Esp. removed the `this` version of it. See #41
  • Loading branch information...
shimaore committed Sep 4, 2012
1 parent 152dc6d commit f5e36513d1f326065146059d8dca26d899365ee0
Showing with 21 additions and 4 deletions.
  1. +17 −0 docs/migrate-0.4.md
  2. +4 −4 src/zappa.coffee
View
@@ -62,3 +62,20 @@ Other changes are Zappa-specific and simplify the API:
@get '/': ->
@params # or this.params
+
+* The `databag` option has been modified.
+ * It is now a boolean, use `@enable 'databag'` to activate it.
+ * The databag is available as `params` (`@params` in coffeecup) to views.
+ This is its only documented use.
+ * All callbacks are called the same way whether databag is enabled or not.
+ Callbacks no longer receive the context (`@`) or the databag as an argument.
+ * If enabled, the databag is available as `@data` in request handlers and
+ request middleware, but it is more efficient to use `@req.param(name)` than
+ `@data.name`, since building the databag might be an expensive operation.
+ Also `@req.param()` is available whether the `databag` setting is enabled or not.
+ * If you were using the object created by the `databag` setting:
+ * Server-side, for `@get`, `@post`, ... and for middleware use `@req.param()`.
+ For `@on` use `@data`.
+ * Client-side, for `@get` use `@params`, and for `@on` use `@data`.
+ * The `param` option value for the `databag` setting is now the *enabled* state of the `databag` setting.
+ * The `this` option value for the `databag` setting has been removed.
View
@@ -340,8 +340,8 @@ zappa.app = (func,options={}) ->
apply_helpers ctx
if app.settings['databag']
- data = {}
- copy_data_to data, [req.query, req.params, req.body]
+ ctx.data = {}
+ copy_data_to ctx.data, [req.query, req.params, req.body]
f.apply ctx
@@ -418,8 +418,8 @@ zappa.app = (func,options={}) ->
apply_helpers ctx
if app.settings['databag']
- data = {}
- copy_data_to data, [req.query, req.params, req.body]
+ ctx.data = {}
+ copy_data_to ctx.data, [req.query, req.params, req.body]
result = r.handler.apply ctx

0 comments on commit f5e3651

Please sign in to comment.