forked from Pylons/pyramid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HISTORY.txt
3929 lines (2946 loc) · 160 KB
/
HISTORY.txt
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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1.4 (2012-12-18)
================
Docs
----
- Fix functional tests in the ZODB tutorial
1.4b3 (2012-12-10)
==================
- Packaging release only, no code changes. 1.4b2 was a brownbag release due to
missing directories in the tarball.
1.4b2 (2012-12-10)
==================
Docs
----
- Scaffolding is now PEP-8 compliant (at least for a brief shining moment).
- Tutorial improvements.
Backwards Incompatibilities
---------------------------
- Modified the ``_depth`` argument to ``pyramid.view.view_config`` to accept
a value relative to the invocation of ``view_config`` itself. Thus, when it
was previously expecting a value of ``1`` or greater, to reflect that
the caller of ``view_config`` is 1 stack frame away from ``venusian.attach``,
this implementation detail is now hidden.
- Modified the ``_backframes`` argument to ``pyramid.util.action_method`` in a
similar way to the changes described to ``_depth`` above. This argument
remains undocumented, but might be used in the wild by some insane person.
1.4b1 (2012-11-21)
==================
Features
--------
- Small microspeed enhancement which anticipates that a
``pyramid.response.Response`` object is likely to be returned from a view.
Some code is shortcut if the class of the object returned by a view is this
class. A similar microoptimization was done to
``pyramid.request.Request.is_response``.
- Make it possible to use variable arguments on ``p*`` commands (``pserve``,
``pshell``, ``pviews``, etc) in the form ``a=1 b=2`` so you can fill in
values in parameterized ``.ini`` file, e.g. ``pshell etc/development.ini
http_port=8080``. See https://github.com/Pylons/pyramid/pull/714
- A somewhat advanced and obscure feature of Pyramid event handlers is their
ability to handle "multi-interface" notifications. These notifications have
traditionally presented multiple objects to the subscriber callable. For
instance, if an event was sent by code like this::
registry.notify(event, context)
In the past, in order to catch such an event, you were obligated to write and
register an event subscriber that mentioned both the event and the context in
its argument list::
@subscriber([SomeEvent, SomeContextType])
def asubscriber(event, context):
pass
In many subscriber callables registered this way, it was common for the logic
in the subscriber callable to completely ignore the second and following
arguments (e.g. ``context`` in the above example might be ignored), because
they usually existed as attributes of the event anyway. You could usually
get the same value by doing ``event.context`` or similar.
The fact that you needed to put an extra argument which you usually ignored
in the subscriber callable body was only a minor annoyance until we added
"subscriber predicates", used to narrow the set of circumstances under which
a subscriber will be executed, in a prior 1.4 alpha release. Once those were
added, the annoyance was escalated, because subscriber predicates needed to
accept the same argument list and arity as the subscriber callables that they
were configured against. So, for example, if you had these two subscriber
registrations in your code::
@subscriber([SomeEvent, SomeContextType])
def asubscriber(event, context):
pass
@subscriber(SomeOtherEvent)
def asubscriber(event):
pass
And you wanted to use a subscriber predicate::
@subscriber([SomeEvent, SomeContextType], mypredicate=True)
def asubscriber1(event, context):
pass
@subscriber(SomeOtherEvent, mypredicate=True)
def asubscriber2(event):
pass
If an existing ``mypredicate`` subscriber predicate had been written in such
a way that it accepted only one argument in its ``__call__``, you could not
use it against a subscription which named more than one interface in its
subscriber interface list. Similarly, if you had written a subscriber
predicate that accepted two arguments, you couldn't use it against a
registration that named only a single interface type.
For example, if you created this predicate::
class MyPredicate(object):
# portions elided...
def __call__(self, event):
return self.val == event.context.foo
It would not work against a multi-interface-registered subscription, so in
the above example, when you attempted to use it against ``asubscriber1``, it
would fail at runtime with a TypeError, claiming something was attempting to
call it with too many arguments.
To hack around this limitation, you were obligated to design the
``mypredicate`` predicate to expect to receive in its ``__call__`` either a
single ``event`` argument (a SomeOtherEvent object) *or* a pair of arguments
(a SomeEvent object and a SomeContextType object), presumably by doing
something like this::
class MyPredicate(object):
# portions elided...
def __call__(self, event, context=None):
return self.val == event.context.foo
This was confusing and bad.
In order to allow people to ignore unused arguments to subscriber callables
and to normalize the relationship between event subscribers and subscriber
predicates, we now allow both subscribers and subscriber predicates to accept
only a single ``event`` argument even if they've been subscribed for
notifications that involve multiple interfaces. Subscribers and subscriber
predicates that accept only one argument will receive the first object passed
to ``notify``; this is typically (but not always) the event object. The
other objects involved in the subscription lookup will be discarded. You can
now write an event subscriber that accepts only ``event`` even if it
subscribes to multiple interfaces::
@subscriber([SomeEvent, SomeContextType])
def asubscriber(event):
# this will work!
This prevents you from needing to match the subscriber callable parameters to
the subscription type unnecessarily, especially when you don't make use of
any argument in your subscribers except for the event object itself.
Note, however, that if the event object is not the first
object in the call to ``notify``, you'll run into trouble. For example, if
notify is called with the context argument first::
registry.notify(context, event)
You won't be able to take advantage of the event-only feature. It will
"work", but the object received by your event handler won't be the event
object, it will be the context object, which won't be very useful::
@subscriber([SomeContextType, SomeEvent])
def asubscriber(event):
# bzzt! you'll be getting the context here as ``event``, and it'll
# be useless
Existing multiple-argument subscribers continue to work without issue, so you
should continue use those if your system notifies using multiple interfaces
and the first interface is not the event interface. For example::
@subscriber([SomeContextType, SomeEvent])
def asubscriber(context, event):
# this will still work!
The event-only feature makes it possible to use a subscriber predicate that
accepts only a request argument within both multiple-interface subscriber
registrations and single-interface subscriber registrations. You needn't
make slightly different variations of predicates depending on the
subscription type arguments. Instead, just write all your subscriber
predicates so they only accept ``event`` in their ``__call__`` and they'll be
useful across all registrations for subscriptions that use an event as their
first argument, even ones which accept more than just ``event``.
However, the same caveat applies to predicates as to subscriber callables: if
you're subscribing to a multi-interface event, and the first interface is not
the event interface, the predicate won't work properly. In such a case,
you'll need to match the predicate ``__call__`` argument ordering and
composition to the ordering of the interfaces. For example, if the
registration for the subscription uses ``[SomeContext, SomeEvent]``, you'll
need to reflect that in the ordering of the parameters of the predicate's
``__call__`` method::
def __call__(self, context, event):
return event.request.path.startswith(self.val)
tl;dr: 1) When using multi-interface subscriptions, always use the event type
as the first subscription registration argument and 2) When 1 is true, use
only ``event`` in your subscriber and subscriber predicate parameter lists,
no matter how many interfaces the subscriber is notified with. This
combination will result in the maximum amount of reusability of subscriber
predicates and the least amount of thought on your part. Drink responsibly.
Bug Fixes
---------
- A failure when trying to locate the attribute ``__text__`` on route and view
predicates existed when the ``debug_routematch`` setting was true or when the
``pviews`` command was used. See https://github.com/Pylons/pyramid/pull/727
Documentation
-------------
- Sync up tutorial source files with the files that are rendered by the
scaffold that each uses.
1.4a4 (2012-11-14)
==================
Features
--------
- ``pyramid.authentication.AuthTktAuthenticationPolicy`` has been updated to
support newer hashing algorithms such as ``sha512``. Existing applications
should consider updating if possible for improved security over the default
md5 hashing.
- Added an ``effective_principals`` route and view predicate.
- Do not allow the userid returned from the ``authenticated_userid`` or the
userid that is one of the list of principals returned by
``effective_principals`` to be either of the strings ``system.Everyone`` or
``system.Authenticated`` when any of the built-in authorization policies that
live in ``pyramid.authentication`` are in use. These two strings are
reserved for internal usage by Pyramid and they will not be accepted as valid
userids.
- Slightly better debug logging from
``pyramid.authentication.RepozeWho1AuthenticationPolicy``.
- ``pyramid.security.view_execution_permitted`` used to return ``True`` if no
view could be found. It now raises a ``TypeError`` exception in that case, as
it doesn't make sense to assert that a nonexistent view is
execution-permitted. See https://github.com/Pylons/pyramid/issues/299.
- Allow a ``_depth`` argument to ``pyramid.view.view_config``, which will
permit limited composition reuse of the decorator by other software that
wants to provide custom decorators that are much like view_config.
- Allow an iterable of decorators to be passed to
``pyramid.config.Configurator.add_view``. This allows views to be wrapped
by more than one decorator without requiring combining the decorators
yourself.
Bug Fixes
---------
- In the past if a renderer returned ``None``, the body of the resulting
response would be set explicitly to the empty string. Instead, now, the body
is left unchanged, which allows the renderer to set a body itself by using
e.g. ``request.response.body = b'foo'``. The body set by the renderer will
be unmolested on the way out. See
https://github.com/Pylons/pyramid/issues/709
- In uncommon cases, the ``pyramid_excview_tween_factory`` might have
inadvertently raised a ``KeyError`` looking for ``request_iface`` as an
attribute of the request. It no longer fails in this case. See
https://github.com/Pylons/pyramid/issues/700
- Be more tolerant of potential error conditions in ``match_param`` and
``physical_path`` predicate implementations; instead of raising an exception,
return False.
- ``pyramid.view.render_view`` was not functioning properly under Python 3.x
due to a byte/unicode discrepancy. See
https://github.com/Pylons/pyramid/issues/721
Deprecations
------------
- ``pyramid.authentication.AuthTktAuthenticationPolicy`` will emit a warning if
an application is using the policy without explicitly passing a ``hashalg``
argument. This is because the default is "md5" which is considered
theoretically subject to collision attacks. If you really want "md5" then you
must specify it explicitly to get rid of the warning.
Documentation
-------------
- All of the tutorials that use
``pyramid.authentication.AuthTktAuthenticationPolicy`` now explicitly pass
``sha512`` as a ``hashalg`` argument.
Internals
---------
- Move ``TopologicalSorter`` from ``pyramid.config.util`` to ``pyramid.util``,
move ``CyclicDependencyError`` from ``pyramid.config.util`` to
``pyramid.exceptions``, rename ``Singleton`` to ``Sentinel`` and move from
``pyramid.config.util`` to ``pyramid.util``; this is in an effort to
move that stuff that may be an API one day out of ``pyramid.config.util``,
because that package should never be imported from non-Pyramid code.
TopologicalSorter is still not an API, but may become one.
- Get rid of shady monkeypatching of ``pyramid.request.Request`` and
``pyramid.response.Response`` done within the ``__init__.py`` of Pyramid.
Webob no longer relies on this being done. Instead, the ResponseClass
attribute of the Pyramid Request class is assigned to the Pyramid response
class; that's enough to satisfy WebOb and behave as it did before with the
monkeypatching.
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 in 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
Not Found 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 ``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.
- The 200-series exception responses named ``HTTPCreated``, ``HTTPAccepted``,
``HTTPNonAuthoritativeInformation``, ``HTTPNoContent``, ``HTTPResetContent``,
and ``HTTPPartialContent`` in ``pyramid.httpexceptions`` no longer inherit
from ``HTTPOk``. Instead they inherit from a new base class named
``HTTPSuccessful``. This will have no effect on you unless you've registered
an exception view for ``HTTPOk`` and expect that exception view to
catch all the aforementioned exceptions.
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.
1.3 (2012-03-21)
================
Bug Fixes
---------
- When ``pyramid.wsgi.wsgiapp2`` calls the downstream WSGI app, the app's
environ will no longer have (deprecated and potentially misleading)
``bfg.routes.matchdict`` or ``bfg.routes.route`` keys in it. A symptom of
this bug would be a ``wsgiapp2``-wrapped Pyramid app finding the wrong view
because it mistakenly detects that a route was matched when, in fact, it
was not.
- The fix for issue https://github.com/Pylons/pyramid/issues/461 (which made
it possible for instance methods to be used as view callables) introduced a
backwards incompatibility when methods that declared only a request
argument were used. See https://github.com/Pylons/pyramid/issues/503
1.3b3 (2012-03-17)
==================
Bug Fixes
---------
- ``config.add_view(<aninstancemethod>)`` raised AttributeError involving
``__text__``. See https://github.com/Pylons/pyramid/issues/461
- Remove references to do-nothing ``pyramid.debug_templates`` setting in all
Pyramid-provided ``.ini`` files. This setting previously told Chameleon to
render better exceptions; now Chameleon always renders nice exceptions
regardless of the value of this setting.
Scaffolds
---------
- The ``alchemy`` scaffold now shows an informative error message in the
browser if the person creating the project forgets to run the
initialization script.
- The ``alchemy`` scaffold initialization script is now called
``initialize_<projectname>_db`` instead of ``populate_<projectname>``.
Documentation
-------------
- Wiki tutorials improved due to collaboration at PyCon US 2012 sprints.
1.3b2 (2012-03-02)
==================
Bug Fixes
---------
- The method ``pyramid.request.Request.partial_application_url`` is no longer
in the API docs. It was meant to be a private method; its publication in
the documentation as an API method was a mistake, and it has been renamed
to something private.
- When a static view was registered using an absolute filesystem path on
Windows, the ``request.static_url`` function did not work to generate URLs
to its resources. Symptom: "No static URL definition matching
c:\\foo\\bar\\baz".
- Make all tests pass on Windows XP.
- Bug in ACL authentication checking on Python 3: the ``permits`` and
``principals_allowed_by_permission`` method of
``pyramid.authorization.ACLAuthenticationPolicy`` could return an
inappropriate ``True`` value when a permission on an ACL was a string
rather than a sequence, and then only if the ACL permission string was a
substring of the ``permission`` value passed to the function.
This bug effects no Pyramid deployment under Python 2; it is a bug that
exists only in deployments running on Python 3. It has existed since
Pyramid 1.3a1.
This bug was due to the presence of an ``__iter__`` attribute on strings
under Python 3 which is not present under strings in Python 2.
1.3b1 (2012-02-26)
==================
Bug Fixes
---------
- ``pyramid.config.Configurator.with_package`` didn't work if the
Configurator was an old-style ``pyramid.configuration.Configurator``
instance.
- Pyramid authorization policies did not show up in the introspector.
Deprecations
------------
- All references to the ``tmpl_context`` request variable were removed from
the docs. Its existence in Pyramid is confusing for people who were never
Pylons users. It was added as a porting convenience for Pylons users in
Pyramid 1.0, but it never caught on because the Pyramid rendering system is
a lot different than Pylons' was, and alternate ways exist to do what it
was designed to offer in Pylons. It will continue to exist "forever" but
it will not be recommended or mentioned in the docs.
1.3a9 (2012-02-22)
==================
Features
--------
- Add an ``introspection`` boolean to the Configurator constructor. If this
is ``True``, actions registered using the Configurator will be registered
with the introspector. If it is ``False``, they won't. The default is
``True``. Setting it to ``False`` during action processing will prevent
introspection for any following registration statements, and setting it to
``True`` will start them up again. This addition is to service a
requirement that the debug toolbar's own views and methods not show up in
the introspector.
- New API: ``pyramid.config.Configurator.add_notfound_view``. This is a
wrapper for ``pyramid.Config.configurator.add_view`` which provides easy
append_slash support and does the right thing about permissions. It should
be preferred over calling ``add_view`` directly with
``context=HTTPNotFound`` as was previously recommended.
- New API: ``pyramid.view.notfound_view_config``. This is a decorator
constructor like ``pyramid.view.view_config`` that calls
``pyramid.config.Configurator.add_notfound_view`` when scanned. It should
be preferred over using ``pyramid.view.view_config`` with
``context=HTTPNotFound`` as was previously recommended.
- New API: ``pyramid.config.Configurator.add_forbidden_view``. This is a
wrapper for ``pyramid.Config.configurator.add_view`` which does the right
thing about permissions. It should be preferred over calling ``add_view``
directly with ``context=HTTPForbidden`` as was previously recommended.
- New API: ``pyramid.view.forbidden_view_config``. This is a decorator
constructor like ``pyramid.view.view_config`` that calls
``pyramid.config.Configurator.add_forbidden_view`` when scanned. It should
be preferred over using ``pyramid.view.view_config`` with
``context=HTTPForbidden`` as was previously recommended.
- New APIs: ``pyramid.response.FileResponse`` and
``pyramid.response.FileIter``, for usage in views that must serve files
"manually".
Backwards Incompatibilities
---------------------------
- Remove ``pyramid.config.Configurator.with_context`` class method. It was
never an API, it is only used by ``pyramid_zcml`` and its functionality has
been moved to that package's latest release. This means that you'll need
to use the 0.9.2 or later release of ``pyramid_zcml`` with this release of
Pyramid.
- The ``introspector`` argument to the ``pyramid.config.Configurator``
constructor API has been removed. It has been replaced by the boolean
``introspection`` flag.
- The ``pyramid.registry.noop_introspector`` API object has been removed.
- The older deprecated ``set_notfound_view`` Configurator method is now an
alias for the new ``add_notfound_view`` Configurator method. Likewise, the
older deprecated ``set_forbidden_view`` is now an alias for the new
``add_forbidden_view``. This has the following impact: the ``context`` sent
to views with a ``(context, request)`` call signature registered via the
``set_notfound_view`` or ``set_forbidden_view`` will now be an exception
object instead of the actual resource context found. Use
``request.context`` to get the actual resource context. It's also
recommended to disuse ``set_notfound_view`` in favor of
``add_notfound_view``, and disuse ``set_forbidden_view`` in favor of
``add_forbidden_view`` despite the aliasing.
Deprecations
------------
- The API documentation for ``pyramid.view.append_slash_notfound_view`` and
``pyramid.view.AppendSlashNotFoundViewFactory`` was removed. These names
still exist and are still importable, but they are no longer APIs. Use
``pyramid.config.Configurator.add_notfound_view(append_slash=True)`` or
``pyramid.view.notfound_view_config(append_slash=True)`` to get the same
behavior.
- The ``set_forbidden_view`` and ``set_notfound_view`` methods of the
Configurator were removed from the documentation. They have been
deprecated since Pyramid 1.1.
Bug Fixes
---------
- The static file response object used by ``config.add_static_view`` opened
the static file twice, when it only needed to open it once.
- The AppendSlashNotFoundViewFactory used request.path to match routes. This
was wrong because request.path contains the script name, and this would
cause it to fail in circumstances where the script name was not empty. It
should have used request.path_info, and now does.
Documentation
-------------
- Updated the "Creating a Not Found View" section of the "Hooks" chapter,
replacing explanations of registering a view using ``add_view`` or
``view_config`` with ones using ``add_notfound_view`` or
``notfound_view_config``.
- Updated the "Creating a Not Forbidden View" section of the "Hooks" chapter,
replacing explanations of registering a view using ``add_view`` or
``view_config`` with ones using ``add_forbidden_view`` or
``forbidden_view_config``.
- Updated the "Redirecting to Slash-Appended Routes" section of the "URL
Dispatch" chapter, replacing explanations of registering a view using
``add_view`` or ``view_config`` with ones using ``add_notfound_view`` or
``notfound_view_config``
- Updated all tutorials to use ``pyramid.view.forbidden_view_config`` rather
than ``pyramid.view.view_config`` with an HTTPForbidden context.
1.3a8 (2012-02-19)
==================
Features
--------
- The ``scan`` method of a ``Configurator`` can be passed an ``ignore``
argument, which can be a string, a callable, or a list consisting of
strings and/or callables. This feature allows submodules, subpackages, and
global objects from being scanned. See
http://readthedocs.org/docs/venusian/en/latest/#ignore-scan-argument for
more information about how to use the ``ignore`` argument to ``scan``.
- Better error messages when a view callable returns a value that cannot be
converted to a response (for example, when a view callable returns a
dictionary without a renderer defined, or doesn't return any value at all).
The error message now contains information about the view callable itself
as well as the result of calling it.
- Better error message when a .pyc-only module is ``config.include`` -ed.
This is not permitted due to error reporting requirements, and a better
error message is shown when it is attempted. Previously it would fail with
something like "AttributeError: 'NoneType' object has no attribute
'rfind'".
- Add ``pyramid.config.Configurator.add_traverser`` API method. See the
Hooks narrative documentation section entitled "Changing the Traverser" for
more information. This is not a new feature, it just provides an API for
adding a traverser without needing to use the ZCA API.
- Add ``pyramid.config.Configurator.add_resource_url_adapter`` API method.
See the Hooks narrative documentation section entitled "Changing How
pyramid.request.Request.resource_url Generates a URL" for more information.
This is not a new feature, it just provides an API for adding a resource
url adapter without needing to use the ZCA API.
- The system value ``req`` is now supplied to renderers as an alias for
``request``. This means that you can now, for example, in a template, do
``req.route_url(...)`` instead of ``request.route_url(...)``. This is
purely a change to reduce the amount of typing required to use request
methods and attributes from within templates. The value ``request`` is
still available too, this is just an alternative.
- A new interface was added: ``pyramid.interfaces.IResourceURL``. An adapter
implementing its interface can be used to override resource URL generation
when ``request.resource_url`` is called. This interface replaces the
now-deprecated ``pyramid.interfaces.IContextURL`` interface.
- The dictionary passed to a resource's ``__resource_url__`` method (see
"Overriding Resource URL Generation" in the "Resources" chapter) now
contains an ``app_url`` key, representing the application URL generated
during ``request.resource_url``. It represents a potentially customized
URL prefix, containing potentially custom scheme, host and port information
passed by the user to ``request.resource_url``. It should be used instead
of ``request.application_url`` where necessary.
- The ``request.resource_url`` API now accepts these arguments: ``app_url``,
``scheme``, ``host``, and ``port``. The app_url argument can be used to
replace the URL prefix wholesale during url generation. The ``scheme``,
``host``, and ``port`` arguments can be used to replace the respective
default values of ``request.application_url`` partially.
- A new API named ``request.resource_path`` now exists. It works like
``request.resource_url`` but produces a relative URL rather than an
absolute one.
- The ``request.route_url`` API now accepts these arguments: ``_app_url``,
``_scheme``, ``_host``, and ``_port``. The ``_app_url`` argument can be
used to replace the URL prefix wholesale during url generation. The
``_scheme``, ``_host``, and ``_port`` arguments can be used to replace the
respective default values of ``request.application_url`` partially.
Backwards Incompatibilities
---------------------------
- The ``pyramid.interfaces.IContextURL`` interface has been deprecated.
People have been instructed to use this to register a resource url adapter
in the "Hooks" chapter to use to influence ``request.resource_url`` URL
generation for resources found via custom traversers since Pyramid 1.0.
The interface still exists and registering such an adapter still works, but
this interface will be removed from the software after a few major Pyramid
releases. You should replace it with an equivalent
``pyramid.interfaces.IResourceURL`` adapter, registered using the new
``pyramid.config.Configurator.add_resource_url_adapter`` API. A
deprecation warning is now emitted when a
``pyramid.interfaces.IContextURL`` adapter is found when
``request.resource_url`` is called.