I'm maintaining a json api with pyramid. And one of the request I
  get on occasion is some way to provide help docs on demand for a
  given endpoint. Something like.....


  /user/login?email=...&password=...

  which maps to a UserModel context with view name = "login"
  would normally call the view but ideally it would be nice to provide
  something like....

  /user/login/__help__ or /user/login?__help__


  if it could return the docstring from the function, the permission
  required, whether the user has the permission or not, and any
  paramaters expected on the request that would be a good start.

  So a response like

   {view:"login",permitted:true, "permission_required":"anonymous",
   parameters:["email","password"]}

  So it seems I need a way to hook into pyramid at the point that the
  context and view are selected, but because the view may be secured i
  need a way to look determine whether it's a call to the view or a
  call to get documentation about the view.

  Since there is no IViewSelected event to subscribe to, my first
  thought was to subscribe to the IContextFound event and take a bit
  of the code from pyramid.views to go through the view selection but
  not call it. This way, I can handle the case where a view
  documentation request comes in.

  The problem is, that this event occurs in a very delicate place
  inside pyramid. I can't raise a new Context and expect the view
  selection machinery to pick it up and do what I'm expecting.

  So, due to copy/pasting code out of pyramid and seeing solutions
  that monkey patch pyramid to get what I want, I'm assuming I'm doing
  it wrong. So, I'm asking if there's a pyramid way to provide what I
  want. I've got the view paramater stuff figured out, I just would
  like to know if there's a pattern I can use to customize what
  happens between after the context is found, and after a view is
  found but before it is ran.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-devel/-/3TtFxZvNyUoJ.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to