ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 02.01.2026
Просмотров: 2671
Скачиваний: 0
31 Extending An Existing Pyramid Application |
355 |
||
31.1 |
The Difference Between “Extensible” and “Pluggable” Applications . . . . . . . . . . . |
355 |
|
31.2 |
Rules for Building An Extensible Application . . . . . . . . . . . . . . . . . . . . . . . |
356 |
|
|
31.2.1 |
Fundamental Plugpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
357 |
31.3 |
Extending an Existing Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
357 |
|
|
31.3.1 If The Application Has Configuration Decorations . . . . . . . . . . . . . . . . |
357 |
|
|
31.3.2 |
Extending the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
358 |
|
31.3.3 |
Overriding Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
359 |
|
31.3.4 |
Overriding Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
360 |
|
31.3.5 |
Overriding Assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
360 |
32 Advanced Configuration |
361 |
||
32.1 |
Conflict Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
361 |
|
|
32.1.1 |
Manually Resolving Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . |
363 |
|
32.1.2 |
Automatic Conflict Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . |
366 |
|
32.1.3 Methods Which Provide Conflict Detection . . . . . . . . . . . . . . . . . . . . |
366 |
|
32.2 |
Including Configuration from External Sources . . . . . . . . . . . . . . . . . . . . . . |
366 |
|
32.3 |
Two-Phase Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
367 |
|
33 Extending Pyramid Configuration |
369 |
||
33.1 |
Adding Methods to the Configurator via add_directive . . . . . . . . . . . . . . . |
369 |
|
33.2 |
Using config.action in a Directive . . . . . . . . . . . . . . . . . . . . . . . . . . |
370 |
|
33.3 |
Adding Configuration Introspection . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
373 |
|
|
33.3.1 |
Introspectable Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
374 |
34 Thread Locals |
377 |
||
34.1 |
Why and How Pyramid Uses Thread Local Variables . . . . . . . . . . . . . . . . . . . |
377 |
|
34.2 |
Why You Shouldn’t Abuse Thread Locals . . . . . . . . . . . . . . . . . . . . . . . . . |
378 |
|
35 Using the Zope Component Architecture in Pyramid |
381 |
||
35.1 |
Using the ZCA Global API in a Pyramid Application . . . . . . . . . . . . . . . . . . . |
382 |
|
|
35.1.1 Disusing the Global ZCA API . . . . . . . . . . . . . . . . . . . . . . . . . . . |
382 |
|
|
35.1.2 Enabling the ZCA Global API by Using hook_zca . . . . . . . . . . . . . . . |
383 |
|
|
35.1.3 Enabling the ZCA Global API by Using The ZCA Global Registry . . . . . . . . |
384 |
|
II Tutorials |
|
387 |
|
36 ZODB + Traversal Wiki Tutorial |
389 |
||
36.1 |
Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
389 |
|
36.2 |
Design |
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
390 |
|
36.2.1 |
Overall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
390 |
|
36.2.2 |
Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
390 |
|
36.2.3 |
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
390 |
|
36.2.4 |
Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
391 |
|
36.2.5 |
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
391 |
36.3 |
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
393 |
|
|
36.3.1 |
Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
393 |
|
36.3.2 |
Make a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
395 |
|
36.3.3 Install the Project in “Development Mode” . . . . . . . . . . . . . . . . . . . . |
396 |
|
|
36.3.4 |
Run the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
396 |
|
36.3.5 Expose Test Coverage Information . . . . . . . . . . . . . . . . . . . . . . . . . |
397 |
|
|
36.3.6 |
Start the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
397 |
|
36.3.7 Visit the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . . . |
398 |
|
|
36.3.8 Decisions the zodb Scaffold Has Made For You . . . . . . . . . . . . . . . . . |
398 |
|
36.4 |
Basic Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
398 |
|
|
36.4.1 Application Configuration with __init__.py . . . . . . . . . . . . . . . . . |
399 |
|
|
36.4.2 Resources and Models with models.py . . . . . . . . . . . . . . . . . . . . . |
400 |
|
|
36.4.3 |
Views With views.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
401 |
|
36.4.4 |
Configuration in development.ini . . . . . . . . . . . . . . . . . . . . . . |
402 |
36.5 |
Defining the Domain Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
403 |
|
|
36.5.1 |
Delete the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
403 |
|
36.5.2 |
Edit models.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
404 |
|
36.5.3 Look at the Result of Our Edits to models.py . . . . . . . . . . . . . . . . . . |
404 |
|
|
36.5.4 View the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . . . |
405 |
|
36.6 |
Defining Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
405 |
|
|
36.6.1 Declaring Dependencies in Our setup.py File . . . . . . . . . . . . . . . . . |
406 |
|
|
36.6.2 |
Adding View Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
408 |
|
36.6.3 Viewing the Result of all Our Edits to views.py . . . . . . . . . . . . . . . . |
411 |
|
|
36.6.4 |
Adding Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
412 |
|
36.6.5 Viewing the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . |
416 |
|
36.7 |
Adding Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
417 |
|
|
36.7.1 Add Authentication and Authorization Policies . . . . . . . . . . . . . . . . . . |
417 |
|
|
36.7.2 |
Add security.py . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
419 |
|
36.7.3 Give Our Root Resource an ACL . . . . . . . . . . . . . . . . . . . . . . . . . |
419 |
|
|
36.7.4 Add Login and Logout Views . . . . . . . . . . . . . . . . . . . . . . . . . . . |
420 |
|
|
36.7.5 |
Change Existing Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
422 |
|
36.7.6 Add permission Declarations to our view_config Decorators . . . . . . . |
422 |
|
|
36.7.7 Add the login.pt Template . . . . . . . . . . . . . . . . . . . . . . . . . . . |
423 |
|
|
36.7.8 Change view.pt and edit.pt . . . . . . . . . . . . . . . . . . . . . . . . . |
424 |
|
|
36.7.9 See Our Changes To views.py and our Templates . . . . . . . . . . . . . . . |
425 |
|
|
36.7.10 View the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . . . |
430 |
|
36.8 |
Adding Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
431 |
|
|
36.8.1 |
Test the Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
431 |
|
36.8.2 |
Test the Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
431 |
|
36.8.3 |
Functional tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
431 |
|
36.8.4 View the results of all our edits to tests.py . . . . . . . . . . . . . . . . . . |
432 |
|
|
36.8.5 |
Run the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
436 |
36.9 |
Distributing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
438 |
|
37 SQLAlchemy + URL Dispatch Wiki Tutorial |
439 |
||
37.1 |
Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
439 |
|
37.2 |
Design |
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
440 |
|
37.2.1 |
Overall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
440 |
|
37.2.2 |
Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
440 |
|
37.2.3 |
Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
440 |
|
37.2.4 |
Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
441 |
|
37.2.5 |
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
441 |
37.3 |
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
443 |
|
|
37.3.1 |
Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
443 |
|
37.3.2 |
Making a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
444 |
|
37.3.3 Installing the Project in “Development Mode” . . . . . . . . . . . . . . . . . . . |
445 |
|
|
37.3.4 |
Running the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
445 |
|
37.3.5 Exposing Test Coverage Information . . . . . . . . . . . . . . . . . . . . . . . |
446 |
|
|
37.3.6 |
Initializing the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
447 |
|
37.3.7 |
Starting the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
448 |
|
37.3.8 Decisions the alchemy Scaffold Has Made For You . . . . . . . . . . . . . . . |
448 |
|
37.4 |
Basic Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
449 |
|
|
37.4.1 Application Configuration with __init__.py . . . . . . . . . . . . . . . . . |
449 |
|
|
37.4.2 View Declarations via views.py . . . . . . . . . . . . . . . . . . . . . . . . . |
451 |
|
|
37.4.3 Content Models with models.py . . . . . . . . . . . . . . . . . . . . . . . . |
452 |
|
37.5 |
Defining the Domain Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
454 |
|
|
37.5.1 Making Edits to models.py . . . . . . . . . . . . . . . . . . . . . . . . . . . |
455 |
|
|
37.5.2 |
Changing scripts/initializedb.py . . . . . . . . . . . . . . . . . . . |
456 |
|
37.5.3 |
Reinitializing the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
457 |
|
37.5.4 Viewing the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . |
458 |
|
37.6 |
Defining Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
459 |
|
|
37.6.1 Declaring Dependencies in Our setup.py File . . . . . . . . . . . . . . . . . |
459 |
|
|
37.6.2 |
Running setup.py develop . . . . . . . . . . . . . . . . . . . . . . . . . |
461 |
|
37.6.3 Changing the views.py File . . . . . . . . . . . . . . . . . . . . . . . . . . . |
461 |
|
|
37.6.4 |
Adding Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
467 |
|
37.6.5 Adding Routes to __init__.py . . . . . . . . . . . . . . . . . . . . . . . . . |
470 |
|
|
37.6.6 Viewing the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . |
472 |
|
37.7 |
Adding Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
472 |
|
|
37.7.1 Adding A Root Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
473 |
|
|
37.7.2 Add an Authorization Policy and an Authentication Policy . . . . . . . . . . . . |
474 |
|
|
37.7.3 Adding an authentication policy callback . . . . . . . . . . . . . . . . . . . . . |
475 |
|
|
37.7.4 Adding Login and Logout Views . . . . . . . . . . . . . . . . . . . . . . . . . . |
476 |
|
|
37.7.5 |
Changing Existing Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
478 |
|
37.7.6 Adding the login.pt Template . . . . . . . . . . . . . . . . . . . . . . . . . |
479 |
|
|
37.7.7 Add a “Logout” link when logged in . . . . . . . . . . . . . . . . . . . . . . . . |
480 |
|
|
37.7.8 Seeing Our Changes To views.py and our Templates . . . . . . . . . . . . . . |
481 |
|
|
37.7.9 Viewing the Application in a Browser . . . . . . . . . . . . . . . . . . . . . . . |
486 |
|
37.8 |
Adding Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
487 |
|
|
37.8.1 |
Testing the Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
487 |
|
37.8.2 |
Testing the Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
487 |
|
37.8.3 |
Functional tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
488 |
|
37.8.4 Viewing the results of all our edits to tests.py . . . . . . . . . . . . . . . . . |
488 |
|
|
37.8.5 |
Running the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
493 |
37.9 |
Distributing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
495 |
|
38 Converting a repoze.bfg Application to Pyramid |
497 |
||
39 Running a Pyramid Application under mod_wsgi |
501 |
||
III |
API Reference |
505 |
|
40 |
pyramid.authorization |
507 |
|
41 |
pyramid.authentication |
509 |
|
|
41.1 |
Authentication Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
509 |
|
41.2 |
Helper Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
513 |
42 |
pyramid.chameleon_text |
515 |
|
43 |
pyramid.chameleon_zpt |
517 |
|
44 |
pyramid.config |
519 |
|
45 |
pyramid.events |
561 |
|
|
45.1 |
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
561 |
|
45.2 |
Event Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
562 |
46 |
pyramid.exceptions |
567 |
|
47 |
pyramid.httpexceptions |
569 |
|
|
47.1 |
HTTP Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
569 |
48 |
pyramid.i18n |
583 |
|
49 |
pyramid.interfaces |
587 |
|
|
49.1 |
Event-Related Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
587 |
|
49.2 |
Other Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
589 |
50 |
pyramid.location |
607 |
|
51 |
pyramid.paster |
609 |
|
52 |
pyramid.registry |
611 |
|
53 |
pyramid.renderers |
613 |
|
54 |
pyramid.request |
617 |
|
55 |
pyramid.response |
643 |
|
|
55.1 |
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
648 |
56 |
pyramid.scripting |
649 |
|
57 |
pyramid.security |
651 |
|
|
57.1 |
Authentication API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
651 |
|
57.2 |
Authorization API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
652 |
|
57.3 |
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
653 |
|
57.4 |
Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
654 |
58 |
pyramid.settings |
655 |
|
59 |
pyramid.testing |
657 |
|
60 |
pyramid.threadlocal |
661 |
|
61 |
pyramid.traversal |
663 |
|
62 |
pyramid.url |
671 |
|
63 |
pyramid.view |
673 |
|
64 |
pyramid.wsgi |
679 |
|
IV Glossary and Index |
681 |
Glossary |
683 |