E&S CVS Commit: PEAK - Lots of peak.web enhancements for resources and templates:

pje at eby-sarna.com pje at eby-sarna.com
Sat Aug 2 16:42:00 EDT 2003

Module Name:	PEAK
Committed By:	pje
Date:		Sat Aug  2 20:41:06 UTC 2003

Modified Files:
	PEAK: setup.py
	PEAK/src/peak/web: interfaces.py places.py publish.py
	    resource_defaults.ini resources.py skins.py templates.py
	PEAK/src/peak/web/tests: __init__.py test_templates.py
Added Files:
	PEAK/src/peak/web/tests: template1.pwt test_resources.py

Log Message:
Lots of peak.web enhancements for resources and templates:

- Added 'web.bindResource("name")'.

- Documented IWebTraversable.preTraverse() better.

- Made IWebTraversable.getObject() take the interaction as a parameter;
  this is ugly but was necessary in order to get bindResource to work.

- Added TestInteraction.simpleTraverse(), to minimize duplicated code in
  interaction-driven tests.

- Made interactions deal in lists of objects traversed so far, rather
  than keeping only the last object.  This was needed so that resources
  used as methods can be bound to their context (the object whose method
  they are) rather than their container (a layer of the skin).  This is
  also ugly but necessary.  :(

- Added caching to ResourceDirectory and Skin, to prevent repeated
  object creation and retrievals.

- Created 'TemplateResource', so you can 'bindResource()' to peak.web
  template files.  Made '.pwt' file extension map to 'TemplateResource'.

At this point, it's clear to me that the traversal mechanisms used by
'peak.web' are ugly as sin and need critical review.  It is *very*
hard to reason clearly about what traversal components do, in part
because they may or may not be decorators over some "real" object.

Skins and Resources further complicate matters by possibly having
different parents, or mixing MultiTraversers into the mix.  Right
now, things seem to work okay, but I'd feel more comfortable if I
could predict/visualize *how* they work.  I keep finding things not
working as I expect, and although I'm able to understand how they
actually work long enough to make them do what I want, I forget soon
afterwards because it's just too darn complicated!

On the bright side, we now have the minimum required functionality, so
perhaps we can now understand the detailed requirements enough to be
able to refactor the implementation appropriately.

To view diffs of this commit, you can use the following URL(s):

To generate a diff of this commit:
cvs rdiff -r1.71 -r1.72 PEAK/setup.py
cvs rdiff -r1.14 -r1.15 PEAK/src/peak/web/interfaces.py
cvs rdiff -r1.13 -r1.14 PEAK/src/peak/web/places.py
cvs rdiff -r1.22 -r1.23 PEAK/src/peak/web/publish.py
cvs rdiff -r1.1 -r1.2 PEAK/src/peak/web/resource_defaults.ini
cvs rdiff -r1.3 -r1.4 PEAK/src/peak/web/resources.py
cvs rdiff -r1.5 -r1.6 PEAK/src/peak/web/skins.py
cvs rdiff -r1.8 -r1.9 PEAK/src/peak/web/templates.py
cvs rdiff -r1.1 -r1.2 PEAK/src/peak/web/tests/__init__.py
cvs rdiff -r0 -r1.1 PEAK/src/peak/web/tests/template1.pwt \
cvs rdiff -r1.5 -r1.6 PEAK/src/peak/web/tests/test_templates.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

More information about the source-changes mailing list