Wilfredo Sánchez Vega
wsanchez at wsanchez.net
Thu Jan 5 22:53:16 MST 2006
I'm wondering how married we are to the child_ method registration
implementation for children in Resource. it's a bit of a strange way
to do this... it means that valid URI characters can't be used, for
Additionally, File doesn't use this mechanism at all, and instead
puts registered children into a dictionary instead. That
implementation is more flexible, but not compatible with the
documented API in its Resource superclass, which says that putChild
("foo", x) means child_foo() = x.
Furthermore, Resource also allows for a childFactory() method to
be a source for children, and that API is also ignored by File. My
feeling is that Resource should be doing none of this at all, and
that there should be two subclasses (ie.
FunkyChildMethodDispatchingResource and FactoryResource) which do one
or the other, if we need these mechanisms to be provided by web2 in a
generic class at all.
Going to the extreme, the notion of resources having children at
all is a strange thing to build into a generic HTTP resource.
Resources that contain other resources (collections) are specified in
WebDAV, but (intentionally) not in HTTP. A lot of implementations
map URIs with slashes in them to a hierarchical back-end (eg. a file
system), but that's not inherrent in HTTP; /foo and /foo/ can be
different and completely unrelated resources. That leads me to think
that locateChild() itself shouldn't be an IResource thing, but
perhaps that's too pedantic given common usage of URI paths.
More information about the Twisted-web