adregner / python-clouddb

Object-oriented Python bindings to the Rackspace Cloud Databases API
Other
3 stars 0 forks source link

validate proper syntax and return responses of DBaaS API calls #3

Open adregner opened 12 years ago

adregner commented 12 years ago

for alex

alunduil commented 12 years ago

clouddb.apibasemodel:

__init__

_load_into_self

path

extended_items

__str__:

Seems strange that this class behaves like an object and as a dict. Seems simpler to provide one consistent interface than trying to merge the two. Which one makes more sense for what this is trying to accomplish?

adregner commented 12 years ago

invoking "self.name" causes a lookup agains the extended_items and the api, which raises an exception for models that don't have a name property.

the str functionality is mainly for my own use in debugging and others that work on this library.

i have refactored and moved the class into clouddb.models and implemented some of the other suggestions. the outstanding issue to be addressed here still are if the data being passed into and out of the underlying API are correct and we are not missing anything. this comparison can be done against the docs (http://docs.rackspace.com/cdb/api/v1.0/cdb-devguide/content/index.html) and your own experimentation. pro tip: this "app" for chrome helps a lot: https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjeloo

alunduil commented 12 years ago

What should the default be in that case? I'm inclined to say that in those cases the path might need to be implemented in that class with the special case. Otherwise, duck type it and pass back something else (or more horrifically: nest getattrs).

You should provide a __str__ method. I'm just suggesting having a static representation. I would create a debug helper for what you're currently trying to with the __str__ method.

I prefer to do my RESTful stuff with curl but I understand that the API is a bit awkward using this mechanism. I would do testing of those inputs in the unittests on the API Handler you have defined. I'll look at the testing infrastructure a bit and update the test bug with any developments.