On 6/5/09 12:37 PM, Chris Rossi wrote:
>
>
> On Fri, Jun 5, 2009 at 12:01 PM, Tres Seaver <tsea...@palladion.com
> <mailto:tsea...@palladion.com>> wrote:
>
>        I'm assuming that we would fix anything in our repository;  it
>     should even be possible to do so in a BBB-compatible way, e.g.::
>
>        def context_factory(environ=None, **kw):
>            match_dict = kw.copy()
>            if environ is not None: # called as "root factory"
>               match_dict.update(environ['repoze.bfg.matchdict'])
>
>
> Ah, right.  Cool.  Making environ a kw arg preserves backwards
> compatability for context factories.  So tweaking my suggestion a little
> bit:
>
> class UnifiedFactory(Interface):
>      def __call__(self, environ=None, **routes_match):
> """
>          Replaces concepts of root factory used for traversal and context
>          factory used for routes, into a single concept.  environ is the
>          WSGI environment, and the match dict from routes matching, if
>          applicable, is passed in as kw args.
> """
>
> I'm sure Chris M will come up with something completely different.

FWIW, the original **kw interface for passing names into a context factory is a 
little awkward already.  For instance, routes match dicts have unicode *keys*. 
This is because the names matched in the PATH_INFO by a pattern might actually 
be themselves encoded; I didn't understand that this was by design until 
recently.  Currently the urldispatch code encodes the keys from Unicode to 
UTF-8 
just so they can be passed as **kw to the context factory (using Unicode keys 
doesn't work when using **kw as function args).  If I had understood that the 
keys were *supposed* to be Unicode from the beginning (instead of strings), 
context factories would have had an interface that looked like this:

def context_factory(match_dict).
     ...

... which isn't really too far off from:

def context_factory(environ):
     match_dict = environ['wgsiorg.routing_args'][1]

What I *should* have done from the very start was to pass the request object in 
to both root factories and context factories.  But it's too late for that now; 
we'd break too many people's apps.

Anyway, I don't really mind changing the urldispatch stuff radically at this 
point; I'll fix the docs and our code and help anyone who needs it change their 
stuff.   If I can make it bwcompat, great, but I'd rather break it now than 
have 
to live with it "forever".

- C
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to