erewok/servant-py

Rewrite Output Functions for better naming and organization

erewok opened this issue · 0 comments

So, I have been thinking about this library and I think I'd like to make the output functions a little more usable. I had the following ideas:

  1. Build Class definitions for URLs where the route is totally common but there are different methods, something like this:
class SomeRoute:
    def __init__(self):
      self.url = "some/url/{param1}/etc"
      pass
    def get(self, param1):
      return requests.get(self.url.format(param1=param1))
   def post(self, param1, payload):
      etc.
  1. Instead of (or in addition to) the above, we could also separate functions into modules so that you can do something like dotted function call:
import some_url_client

some_url_client.get()

The default way of naming functions creates really long functions, so we need something consistent that also creates an API that's not ultimately painful to use.

I'll experiment and try to see what'll work best.