Re: [PATCH] Re: [Myghty-users] routes and myghty
Brought to you by:
zzzeek
From: Ben B. <be...@gr...> - 2005-10-27 19:36:33
|
On Oct 27, 2005, at 1:26 AM, Jamie Wilkinson wrote: > So it's probably going to completely break all the paste stuff that > relied > on 'controller' referring to a filename with a _controller.py > suffix. It > also requires that you call create_regs on the routes mapper yourself, > rather than leave it to the resolver (but I assume there's a way to > pull out > all the mappings? Maybe RoutesResolver should take a dictionary like > ResolveModule did?) Ouch, the create_regs thing is pretty harsh. If you have a directory of controllers with 50 controllers under various sub-dirs, it's going to suck specifying every single one of those in a dictionary (thus the _find_controllers code). Having Routes just find them all and use them is a pretty core type of thing, but it does require the user to follow a pattern of specifying the filename so it knows what to pick up inside the file without having to do even more scanning. What I'm considering though based on your feedback, is one or both of the following additional RoutesResolver options, RoutesResolver(mapper=m, controller_root='/app/controllers') # Will scan controller dir and sub-dirs every request RoutesResolver(mapper=m, controller_root='/app/controllers', scan_controllers=False) # Will scan controller dir only at start-up RoutesResolver(mapper=m, controller_root='/app/controllers', controller_postfix='.py') # Any file ending in .py is considered a valid controller rather than _controller.py How's that look? This way the default behavior doesn't change, but for those that really want to tweak it out, they can. I'd prefer to hide this flexibility because things are confusing enough with the amount of options available for dispatching. Uniform schemes for discovering controllers is convenient and for those that for some reason can't stand the though of having their controller file end in _controller.py can change the postfix. :) This should make it easier to use the RoutesResolver outside of the Paste template, where some of the config stuff won't be done for you while not changing things for those using the Paste template. If you're still preferring more radical modification of it, > There's also a few lines where tabs were converted to 4-spaces. Bizarre, must be left-over from when Mike changed all the formatting from tabs to 4-spaces. Cheers, Ben |