Letractively / kay-framework

Automatically exported from code.google.com/p/kay-framework
Other
0 stars 0 forks source link

adding werkzeug like custom converter in viewgroup #104

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
http://werkzeug.pocoo.org/docs/routing/#builtin-converters

although kay uses werkzeug internally, it does not yet support custom 
converter. 

having custom converter configurable inside setting will be good enough. 

Original issue reported on code.google.com by patelgo...@gmail.com on 5 Apr 2011 at 9:16

GoogleCodeExporter commented 8 years ago
changing line 152, kay/app.py 

from 

url_map = Map(copy.deepcopy(base_rules))

to

url_map = Map(copy.deepcopy(base_rules),converters=[(key,import_string(value)) 
for key,value in self.app_settings.URL_CONVERTERS.items()])

and URL_CONVERTERS = { "NAME": "PATH" } in settings.py 

will do the trick. 

Original comment by patelgo...@gmail.com on 5 Apr 2011 at 10:23

GoogleCodeExporter commented 8 years ago
nope, above will not work as rule and viewgroup evaluated before it reach the 
app.py, but can't we make it lazy ?

i.e. instead of 

view_groups = [
  ViewGroup(
    Rule('/', endpoint='index', view='app.views.index'),
  )
]

can we have

view_groups = [
  (
    {'path':'/', 'endpoint':'index', 'view':'app.views.index'},
  )
]
which can be evaluated inside app.py  ?

Original comment by patelgo...@gmail.com on 5 Apr 2011 at 10:31

GoogleCodeExporter commented 8 years ago

Original comment by IanMLe...@gmail.com on 30 Apr 2011 at 10:17