watsonpy / watson-framework

A Python 3 web app framework.
BSD 3-Clause "New" or "Revised" License
104 stars 12 forks source link

method invoke problem in options.action #26

Closed dalirnet closed 4 years ago

dalirnet commented 7 years ago

hi!

routes = {
    'index': {
        'path': '/',
        'options': {'controller': 'app_name.controllers.Public', 'action': 'index'}
    },
}

if change action to other name this method not work and return this error AttributeError: 'MainController' object has no attribute 'index_action'

my route file is:

routes = {
    'indexPage': {
        'path': '/',
        'options': {
            'controller': 'cssObject.controllers.MainController',
            'action': 'indexPage'
        }
    }
}
dalirnet commented 7 years ago

i changed two files

1- [framework/listeners.py:61,69]

execute_params = route_match.params

to

execute_params = {**route_match.params, **route_match.route.options}

and

path = controller.get_execute_method_path(
                **route_match.params)

to

path = controller.get_execute_method_path(
                **execute_params)

2- [framework/controllers.py:344]

del actual_kwargs['action']

to

del actual_kwargs['action']
del actual_kwargs['controller']

now solved problem, but is this change true?