Chris McDonough
2012-10-26 4a6cca62ddf33580b1de210ef5ca54bfb2769243
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
1.4a3 (2012-10-26)
==================
 
Bug Fixes
---------
 
- The match_param predicate's text method was fixed to sort its values.
  Part of https://github.com/Pylons/pyramid/pull/705
 
- 1.4a ``pyramid.scripting.prepare`` behaved differently than 1.3 series
  function of same name.  In particular, if passed a request, it would not
  set the ``registry`` attribute of the request like 1.3 did.  A symptom
  would be that passing a request to ``pyramid.paster.bootstrap`` (which uses
  the function) that did not have a ``registry`` attribute could assume that
  the registry would be attached to the request by Pyramid.  This assumption
  could be made in 1.3, but not in 1.4.  The assumption can now be made in
  1.4 too (a registry is attached to a request passed to bootstrap or
  prepare).
 
- When registering a view configuration that named a Chameleon ZPT renderer
  with a macro name in it (e.g. ``renderer='some/template#somemacro.pt``) as
  well as a view configuration without a macro name it it that pointed to the
  same template (e.g. ``renderer='some/template.pt'``), internal caching could
  confuse the two, and your code might have rendered one instead of the
  other.
 
Features
--------
 
- Allow multiple values to be specified to the ``request_param`` view/route
  predicate as a sequence.  Previously only a single string value was allowed.
  See https://github.com/Pylons/pyramid/pull/705
 
- Comments with references to documentation sections placed in scaffold
  ``.ini`` files.
 
- Added an HTTP Basic authentication policy
  at ``pyramid.authentication.BasicAuthAuthenticationPolicy``.
 
- The Configurator ``testing_securitypolicy`` method now returns the policy
  object it creates.
 
- The Configurator ``testing_securitypolicy`` method accepts two new
  arguments: ``remember_result`` and ``forget_result``.  If supplied, these
  values influence the result of the policy's ``remember`` and ``forget``
  methods, respectively.
 
- The DummySecurityPolicy created by ``testing_securitypolicy`` now sets a
  ``forgotten`` value on the policy (the value ``True``) when its ``forget``
  method is called.
 
- The DummySecurityPolicy created by ``testing_securitypolicy`` now sets a
  ``remembered`` value on the policy, which is the value of the ``principal``
  argument it's called with when its ``remember`` method is called.
 
- New ``physical_path`` view predicate.  If specified, this value should be a
  string or a tuple representing the physical traversal path of the context
  found via traversal for this predicate to match as true.  For example:
  ``physical_path='/'`` or ``physical_path='/a/b/c'`` or ``physical_path=('',
  'a', 'b', 'c')``.  This is not a path prefix match or a regex, it's a
  whole-path match.  It's useful when you want to always potentially show a
  view when some object is traversed to, but you can't be sure about what kind
  of object it will be, so you can't use the ``context`` predicate.  The
  individual path elements inbetween slash characters or in tuple elements
  should be the Unicode representation of the name of the resource and should
  not be encoded in any way.
 
1.4a2 (2012-09-27)
==================
 
Bug Fixes
---------
 
- When trying to determine Mako defnames and Chameleon macro names in asset
  specifications, take into account that the filename may have a hyphen in
  it.  See https://github.com/Pylons/pyramid/pull/692
 
Features
--------
 
- A new ``pyramid.session.check_csrf_token`` convenience function was added.
 
- A ``check_csrf`` view predicate was added.  For example, you can now do
  ``config.add_view(someview, check_csrf=True)``.  When the predicate is
  checked, if the ``csrf_token`` value in ``request.params`` matches the CSRF
  token in the request's session, the view will be permitted to execute.
  Otherwise, it will not be permitted to execute.
 
- Add ``Base.metadata.bind = engine`` to alchemy template, so that tables
  defined imperatively will work.
 
Documentation
-------------
 
- update wiki2 SQLA tutorial with the changes required after inserting
  ``Base.metadata.bind = engine`` into the alchemy scaffold.
 
1.4a1 (2012-09-16)
==================
 
Bug Fixes
---------
 
- Forward port from 1.3 branch: When no authentication policy was configured,
  a call to ``pyramid.security.effective_principals`` would unconditionally
  return the empty list.  This was incorrect, it should have unconditionally
  returned ``[Everyone]``, and now does.
 
- Explicit url dispatch regexes can now contain colons.
  https://github.com/Pylons/pyramid/issues/629
 
- On at least one 64-bit Ubuntu system under Python 3.2, using the
  ``view_config`` decorator caused a ``RuntimeError: dictionary changed size
  during iteration`` exception.  It no longer does.  See
  https://github.com/Pylons/pyramid/issues/635 for more information.
 
- In Mako Templates lookup, check if the uri is already adjusted and bring
  it back to an asset spec. Normally occurs with inherited templates or
  included components.
  https://github.com/Pylons/pyramid/issues/606
  https://github.com/Pylons/pyramid/issues/607
 
- In Mako Templates lookup, check for absolute uri (using mako directories) 
  when mixing up inheritance with asset specs.
  https://github.com/Pylons/pyramid/issues/662
 
- HTTP Accept headers were not being normalized causing potentially
  conflicting view registrations to go unnoticed. Two views that only
  differ in the case ('text/html' vs. 'text/HTML') will now raise an error.
  https://github.com/Pylons/pyramid/pull/620
 
- Forward-port from 1.3 branch: when registering multiple views with an
  ``accept`` predicate in a Pyramid application runing under Python 3, you
  might have received a ``TypeError: unorderable types: function() <
  function()`` exception.
 
Features
--------
 
- Configurator.add_directive now accepts arbitrary callables like partials or
  objects implementing ``__call__`` which dont have ``__name__`` and
  ``__doc__`` attributes.  See https://github.com/Pylons/pyramid/issues/621
  and https://github.com/Pylons/pyramid/pull/647.
 
- Third-party custom view, route, and subscriber predicates can now be added
  for use by view authors via
  ``pyramid.config.Configurator.add_view_predicate``,
  ``pyramid.config.Configurator.add_route_predicate`` and
  ``pyramid.config.Configurator.add_subscriber_predicate``.  So, for example,
  doing this::
 
     config.add_view_predicate('abc', my.package.ABCPredicate)
 
  Might allow a view author to do this in an application that configured that
  predicate::
 
     @view_config(abc=1)
 
  Similar features exist for ``add_route``, and ``add_subscriber``.  See
  "Adding A Third Party View, Route, or Subscriber Predicate" in the Hooks
  chapter for more information.
 
  Note that changes made to support the above feature now means that only
  actions registered using the same "order" can conflict with one another.
  It used to be the case that actions registered at different orders could
  potentially conflict, but to my knowledge nothing ever depended on this
  behavior (it was a bit silly).
 
- Custom objects can be made easily JSON-serializable in Pyramid by defining
  a ``__json__`` method on the object's class. This method should return
  values natively serializable by ``json.dumps`` (such as ints, lists,
  dictionaries, strings, and so forth).
 
- The JSON renderer now allows for the definition of custom type adapters to
  convert unknown objects to JSON serializations.
 
- As of this release, the ``request_method`` predicate, when used, will also
  imply that ``HEAD`` is implied when you use ``GET``.  For example, using
  ``@view_config(request_method='GET')`` is equivalent to using
  ``@view_config(request_method=('GET', 'HEAD'))``.  Using
  ``@view_config(request_method=('GET', 'POST')`` is equivalent to using
  ``@view_config(request_method=('GET', 'HEAD', 'POST')``.  This is because
  HEAD is a variant of GET that omits the body, and WebOb has special support
  to return an empty body when a HEAD is used.
 
- ``config.add_request_method`` has been introduced to support extending
  request objects with arbitrary callables. This method expands on the
  previous ``config.set_request_property`` by supporting methods as well as
  properties. This method now causes less code to be executed at
  request construction time than ``config.set_request_property`` in
  version 1.3.
 
- Don't add a ``?`` to URLs generated by ``request.resource_url`` if the
  ``query`` argument is provided but empty.
 
- Don't add a ``?`` to URLs generated by ``request.route_url`` if the
  ``_query`` argument is provided but empty.
 
- The static view machinery now raises (rather than returns) ``HTTPNotFound``
  and ``HTTPMovedPermanently`` exceptions, so these can be caught by the
  NotFound view (and other exception views).
 
- The Mako renderer now supports a def name in an asset spec.  When the def
  name is present in the asset spec, the system will render the template def
  within the template and will return the result. An example asset spec is
  ``package:path/to/template#defname.mako``. This will render the def named
  ``defname`` inside the ``template.mako`` template instead of rendering the
  entire template.  The old way of returning a tuple in the form
  ``('defname', {})`` from the view is supported for backward compatibility,
 
- The Chameleon ZPT renderer now accepts a macro name in an asset spec.  When
  the macro name is present in the asset spec, the system will render the
  macro listed as a ``define-macro`` and return the result instead of
  rendering the entire template.  An example asset spec:
  ``package:path/to/template#macroname.pt``.  This will render the macro
  defined as ``macroname`` within the ``template.pt`` template instead of the
  entire templae.
 
- When there is a predicate mismatch exception (seen when no view matches for
  a given request due to predicates not working), the exception now contains
  a textual description of the predicate which didn't match.
 
- An ``add_permission`` directive method was added to the Configurator.  This
  directive registers a free-standing permission introspectable into the
  Pyramid introspection system.  Frameworks built atop Pyramid can thus use
  the the ``permissions`` introspectable category data to build a
  comprehensive list of permissions supported by a running system.  Before
  this method was added, permissions were already registered in this
  introspectable category as a side effect of naming them in an ``add_view``
  call, this method just makes it possible to arrange for a permission to be
  put into the ``permissions`` introspectable category without naming it
  along with an associated view.  Here's an example of usage of
  ``add_permission``::
 
      config = Configurator()
      config.add_permission('view')
 
- The ``UnencryptedCookieSessionFactoryConfig`` now accepts
  ``signed_serialize`` and ``signed_deserialize`` hooks which may be used
  to influence how the sessions are marshalled (by default this is done
  with HMAC+pickle).
 
- ``pyramid.testing.DummyRequest`` now supports methods supplied by the
  ``pyramid.util.InstancePropertyMixin`` class such as ``set_property``.
 
- Request properties and methods added via ``config.set_request_property`` or
  ``config.add_request_method`` are now available to tweens.
 
- Request properties and methods added via ``config.set_request_property`` or
  ``config.add_request_method`` are now available in the request object
  returned from ``pyramid.paster.bootstrap``.
 
- ``request.context`` of environment request during ``bootstrap`` is now the
  root object if a context isn't already set on a provided request.
 
- The ``pyramid.decorator.reify`` function is now an API, and was added to
  the API documentation.
 
- Added the ``pyramid.testing.testConfig`` context manager, which can be used
  to generate a configurator in a test, e.g. ``with testing.testConfig(...):``.
 
- Users can now invoke a subrequest from within view code using a new
  ``request.invoke_subrequest`` API.
 
Deprecations
------------
 
- The ``pyramid.config.Configurator.set_request_property`` has been
  documentation-deprecated.  The method remains usable but the more
  featureful ``pyramid.config.Configurator.add_request_method`` should be
  used in its place (it has all of the same capabilities but can also extend
  the request object with methods).
 
Backwards Incompatibilities
---------------------------
 
- The Pyramid router no longer adds the values ``bfg.routes.route`` or
  ``bfg.routes.matchdict`` to the request's WSGI environment dictionary.
  These values were docs-deprecated in ``repoze.bfg`` 1.0 (effectively seven
  minor releases ago).  If your code depended on these values, use
  request.matched_route and request.matchdict instead.
 
- It is no longer possible to pass an environ dictionary directly to
  ``pyramid.traversal.ResourceTreeTraverser.__call__`` (aka
  ``ModelGraphTraverser.__call__``).  Instead, you must pass a request
  object.  Passing an environment instead of a request has generated a
  deprecation warning since Pyramid 1.1.
 
- Pyramid will no longer work properly if you use the
  ``webob.request.LegacyRequest`` as a request factory.  Instances of the
  LegacyRequest class have a ``request.path_info`` which return a string.
  This Pyramid release assumes that ``request.path_info`` will
  unconditionally be Unicode.
 
- The functions from ``pyramid.chameleon_zpt`` and ``pyramid.chameleon_text``
  named ``get_renderer``, ``get_template``, ``render_template``, and
  ``render_template_to_response`` have been removed.  These have issued a
  deprecation warning upon import since Pyramid 1.0.  Use
  ``pyramid.renderers.get_renderer()``,
  ``pyramid.renderers.get_renderer().implementation()``,
  ``pyramid.renderers.render()`` or ``pyramid.renderers.render_to_response``
  respectively instead of these functions.
 
- The ``pyramid.configuration`` module was removed.  It had been deprecated
  since Pyramid 1.0 and printed a deprecation warning upon its use.  Use
  ``pyramid.config`` instead.
 
- The ``pyramid.paster.PyramidTemplate`` API was removed.  It had been
  deprecated since Pyramid 1.1 and issued a warning on import.  If your code
  depended on this, adjust your code to import
  ``pyramid.scaffolds.PyramidTemplate`` instead.
 
- The ``pyramid.settings.get_settings()`` API was removed.  It had been
  printing a deprecation warning since Pyramid 1.0.  If your code depended on
  this API, use ``pyramid.threadlocal.get_current_registry().settings``
  instead or use the ``settings`` attribute of the registry available from
  the request (``request.registry.settings``).
 
- These APIs from the ``pyramid.testing`` module were removed.  They have
  been printing deprecation warnings since Pyramid 1.0:
 
  * ``registerDummySecurityPolicy``, use
    ``pyramid.config.Configurator.testing_securitypolicy`` instead.
 
  * ``registerResources`` (aka ``registerModels``, use
    ``pyramid.config.Configurator.testing_resources`` instead.
 
  * ``registerEventListener``, use
    ``pyramid.config.Configurator.testing_add_subscriber`` instead.
 
  * ``registerTemplateRenderer`` (aka `registerDummyRenderer``), use
    ``pyramid.config.Configurator.testing_add_template`` instead.
 
  * ``registerView``, use ``pyramid.config.Configurator.add_view`` instead.
 
  * ``registerUtility``, use
    ``pyramid.config.Configurator.registry.registerUtility`` instead.
 
  * ``registerAdapter``, use
    ``pyramid.config.Configurator.registry.registerAdapter`` instead.
 
  * ``registerSubscriber``, use 
    ``pyramid.config.Configurator.add_subscriber`` instead.
 
  * ``registerRoute``, use 
    ``pyramid.config.Configurator.add_route`` instead.
 
  * ``registerSettings``, use 
    ``pyramid.config.Configurator.add_settings`` instead.
 
- In Pyramid 1.3 and previous, the ``__call__`` method of a Response object
  was invoked before any finished callbacks were executed.  As of this
  release, the ``__call__`` method of a Response object is invoked *after*
  finished callbacks are executed.  This is in support of the
  ``request.invoke_subrequest`` feature.
 
Documentation
-------------
 
- Added an "Upgrading Pyramid" chapter to the narrative documentation.  It
  describes how to cope with deprecations and removals of Pyramid APIs and
  how to show Pyramid-generated deprecation warnings while running tests and
  while running a server.
 
- Added a "Invoking a Subrequest" chapter to the documentation.  It describes
  how to use the new ``request.invoke_subrequest`` API.
 
Dependencies
------------
 
- Pyramid now requires WebOb 1.2b3+ (the prior Pyramid release only relied on
  1.2dev+).  This is to ensure that we obtain a version of WebOb that returns
  ``request.path_info`` as text.