balanced/balanced-python — pull request #25 by mjallday (2013-02-12 21:01:57+00:00)
Title: allow nesting of objects under resources other than the marketplace

Problem:

class Log(resource):
# matches /v1/marketplaces/logs
__metaclass__ = resource_base(collection='logs')

class EventCallbackLog(resource):
# oh noes, balanced will map all log objects as EventCallbackLog
__metaclass__ = resource_base(collection='logs')

Solution:

class Log(resource):
__metaclass__ = resource_base(collection='logs')

class EventCallbackLog(resource):
# yay, we use the path of the resource to see if the nesting matches
# matches only /v1/events/E1/callbacks/C1/logs
__metaclass__ = resource_base(collection='logs', nested_under=['events', 'callbacks'])

An alternative implementation would be to return `__type__` on the API response and then use a registry to look that up.