[ckan-dev] Overriding controllers in plugins?

Koebrick, Andrew (MNIT) andrew.koebrick at state.mn.us
Wed Aug 5 16:21:37 UTC 2015


Is it possible to override a stock CKAN controller in a plugin?  I am attempting to load a new controller for controllers.user.read.  I want to restrict access so only users themselves can see their own profiles.

I tried to use the before_map class from IRoutes like this, so that my custom read controller would be called:
            m.connect('user_datasets', '/user/{id:.*}', action='mngeo_user_read', ckan_icon='sitemap')

I was hoping this would override this mapping from config.routing:
        m.connect('user_datasets', '/user/{id:.*}', action='read',
                  ckan_icon='sitemap')

The trouble I am having seems to be that since this is being implemented _before_ the routes in config.routing, it is "greedy" and is catching requests to pages such as user/login

Using the after_map would seem to implement my class too late.

I also tried to not use any IRoutes and just have my replacement controller named "read" hoping it would take the place of the main ckan controller.

Can anyone explain how I can get my own controller to get mapped?  Or if I appear to be just generally confused, set me on the right path?

Many thanks,

Andrew Koebrick  |  MINNESOTA GEOSPATIAL INFORMATION OFFICE
Web Coordinator / Systems administrator / Librarian
MN.IT Services @ MNGEO
651-201-2465 (w)  |   651-296-6398 (f) |  andrew.koebrick at state.mn.us<mailto:andrew.koebrick at state.mn.us>
658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us<http://www.mngeo.state.mn.us/>

[cid:image002.jpg at 01CE61F8.52552AE0]<http://www.mn.gov/oet>

Information Technology for Minnesota Government   |   mn.gov/mnit<http://www.mn.gov/oet>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150805/a301e8de/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: image001.jpg
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150805/a301e8de/attachment-0002.jpg>


More information about the ckan-dev mailing list