and though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here

  1. 23 Nov, 2016 1 commit
    • Jordan Moldow's avatar
      Prepare for next 2.0.0 alpha release (#183) · baf536cf
      Jordan Moldow authored
      Bump version to 2.0.0a3.
      
      Add new release notes.
      
      Start running tests against the development build of Python 3.6
      (which is currently in a feature-freeze beta).
      
      gitignore more patterns for Python virtualenv directories.
      
      `six.with_metaclass()` doesn't work with `enum.EnumMeta` in
      Python 3.6, because of logic that was added to
      `EnumMeta.__prepare__()`. The six bug actually applies to all
      versions of Python 3, but I guess it was never noticed until
      now.
      
      This adds our own `with_metaclass()` helper function, with the
      fix applied to it. Later I'll submit the same patch to six.
      Explanation of the bug and the fix are in the docstring.
      
      jsonpatch is not currently compatible with Python 3.6. If we
      can't load it during functional testing, then
      `@chaos_utils.patch()` will be a no-op.
      baf536cf
  2. 10 Nov, 2016 1 commit
  3. 09 Nov, 2016 2 commits
  4. 22 Sep, 2016 3 commits
    • Jordan Moldow's avatar
      Allow passing user and enterprise_id to JWTAuth · 4bea8654
      Jordan Moldow authored
      The initial commit that added the `user` parameter to `JWTAuth`
      only allowed it to be passed when `enterprise_id=None` was
      passed.
      
      After playing around with this a little bit, I determined that
      this is unnecessarily inflexible for developers. So this
      constraint is now relaxed. They can both be passed, with `user`
      taking precedence.
      
      Fixup for Pull Request #178.
      4bea8654
    • Jordan Moldow's avatar
      Refactors to JWTAuth · 12fb081c
      Jordan Moldow authored
      Rename `JWTAuth.authenticate_app_user()` to
      `JWTAuth.authenticate_user()`, to reflect the fact that the new
      Box service accounts can authenticate as managed users as well
      as app users. `JWTAuth.authenticate_app_user()` is retained as
      an alias, for backwards-compatability.
      
      Allow a user ID to be passed to `JWTAuth`, instead of a `User`
      object. Previously, developers would need to import and manually
      construct a `boxsdk.object.user.User`, since `Client.user()`
      cannot be used until the `Client` has been constructed (which is
      usually done after all authentication is complete).
      
      Allow a user or user ID to be passed to the `JWTAuth`
      constructor. This way, `JWTAuth.authenticate_user()` can be
      called without any arguments. More importantly, this means that
      `JWTAuth.refresh()` can be called immediately after
      construction, with no need for a manual call to
      `JWTAuth.authenticate_user()`.
      
      When `auto_session_renewal=True`, if there is no access token,
      then `BoxSession.request()` will renew the token _before_ making
      the request. This saves an API call. And combined with the
      above, authentication for `JWTAuth` objects can be done
      completely automatically, at the time of first API call.
      
      Document that the `enterprise_id` argument to `JWTAuth` is
      allowed to be `None` (and must be `None` if `user` is passed).
      Also allow it to be passed to `authenticate_instance()`, so that
      it doesn't need to be provided at construction time.
      
      Clean up the README.
      
      Fixes #174.
      12fb081c
    • Jordan Moldow's avatar
      Logging refactors and improvements · d3b87fcd
      Jordan Moldow authored
      Move response logging to a new `LoggingNetworkResponse` class.
      This allows us to decide whether to log the response body, based
      on whether the caller reads or streams the content. This fixes a
      bug introduced by Pull Request #166, where the `LoggingNetwork`
      would always omit logging the response body.
      
      Add a `network_response_constructor` property to
      `DefaultNetwork`, to make it easier for subclasses to return
      their own `NetworkResponse` subclasses. Use this in
      `LoggingNetwork`, to return `LoggingNetworkResponse` instances.
      Also add it as an optional property on the `Network` interface
      class.
      
      In `network_interface.py`, switch some usages of
      `@abc.abstractmethod` to `@abc.abstractproperty`. This doesn't
      matter on recent versions of Python 3, but there is a difference
      between the two on Python 2, plus it makes the interface
      clearer. This is a backwards-compatible change, because the SDK
      uses these as properties, so any custom implementations would've
      needed to implement these with `property` anyway.
      
      Update the logging format strings in `LoggingNetwork`, to make
      them more informative and also easier to override (by using
      keyword format placeholders instead of positional ones). This is
      a breaking change for clients that were overriding these class
      attributes.
      
      Add logging for request exceptions in `LoggingNetwork`.
      
      Use the `LoggingNetwork` during functional tests.
      
      Switch some stateful mock fixtures from session scope to
      function scope.
      d3b87fcd
  5. 08 Sep, 2016 5 commits
  6. 07 Sep, 2016 4 commits
  7. 03 Sep, 2016 1 commit
    • Jordan Moldow's avatar
      Refactor Translator to use less global state (#165) · 719a831d
      Jordan Moldow authored
      In the past, there was one `Translator`, which was a global
      singleton, and would be permanently modified any time a new
      object class with an `_item_type` was created.
      
      Recently, in v2.0.0a1, we tried out a change where the global
      translator would be modified any time a new object class with an
      `_item_type` OR with a baseclass with an `_item_type` was created.
      This means that every subclass operation mutated global state.
      We thought this would make it easier for developers to add their
      own classes to the SDK. In retrospect, it makes it much harder
      to write tests (because any temporary subclasses created,
      including by a mock library, will modify global state for the
      rest of the test run), and makes it impossible to intentionally
      create a subclass that shouldn't be registered in the
      translator. So we are reverting this behavior for v2.0.0a2.
      
      Furthermore, this adds the ability to create non-global
      translators (which are, by default, used on `BoxSession`
      objects), and the ability to add non-global registrations to
      these non-global translators. This is now the publicly
      recommended way for developers to register types, outside of the
      SDK itself.
      
      For now, the old mechanism of implicitly registering the
      official SDK classes with `_item_type` is retained. But we can
      experiment with the new system, and see if we prefer to switch
      to the explicit registration, and delete the implicit
      registration system, in v2.0.0a3.
      
      Also fix a bug that I discovered in `ExtendableEnumMeta`.
      719a831d
  8. 19 Aug, 2016 3 commits
    • Jordan Moldow's avatar
      Merge pull request #160 · e325da58
      Jordan Moldow authored
      Prepare for alpha release of 2.0.0
      
      Bump version to 2.0.0a1.
      
      Add @kelseymorris95 to AUTHORS.
      
      Fix up docstrings for Sphinx, and update docs sources.
      
      Clean up release notes.
      e325da58
    • Jordan Moldow's avatar
      Prepare for alpha release of 2.0.0 · 8374720c
      Jordan Moldow authored
      Bump version to 2.0.0a1.
      
      Add @kelseymorris95 to AUTHORS.
      
      Fix up docstrings for Sphinx, and update docs sources.
      
      Clean up release notes.
      8374720c
    • kelseymorris95's avatar
      Docs update (#159) · 309336d4
      kelseymorris95 authored
      Update HISTORY and README for new release.
      309336d4
  9. 18 Aug, 2016 2 commits
  10. 17 Aug, 2016 1 commit
    • kelseymorris95's avatar
      Add Cloneable interface and @api_call (#154) · 6199de87
      kelseymorris95 authored
      New `@api_call` decorator can be used to allow methods that make an API call to accept an extra
      parameter `extra_network_parameters`, to be used for sending low level request parameters to
      Requests or whatever network layer is being used.
      
      When `extra_network_parameters` is provided, the underlying `BoxSession` is cloned, and the
      `extra_network_parameters` are attached to the new one.
      
      Decorate all existing API call methods with `@api_call`.
      6199de87
  11. 15 Aug, 2016 2 commits
  12. 01 Aug, 2016 5 commits
  13. 08 Jul, 2016 1 commit
    • kelseymorris95's avatar
      Allow custom subclasses of smart objects (#149) · 3f5908c8
      kelseymorris95 authored
      Enable `Translator` registered subclasses of smart objects to be returned
      from smart object methods.
      
      Remove all hard coded smart object return types in favor of a lookup in
      `Translator` or returning an instance of `self.__class__`.
      3f5908c8
  14. 21 Jun, 2016 1 commit
    • kelseymorris95's avatar
      Add Event class (#139) · 76652d96
      kelseymorris95 authored
      Added an `Event` class, edited `Events.get_event()` to return a list of them.
      
      This creates a new branch in the object class hierarchy, with a distinction between REST objects (instances of `BaseObject` and its subclasses) and non-REST (objects that are not addressable / queryable in the API) objects (instances of `APIJSONObject` and its subclasses). `BaseObject` and `APIJSONObject` inherit from a common baseclass, `BaseAPIJSONObject`, which is now the base for translation.
      
      To maintain backwards-compatibility with methods that used to return `dict`, `APIJSONObject` implements the `Mapping` interface.
      
      Fixes #15.
      76652d96
  15. 26 May, 2016 2 commits
    • Jordan Moldow's avatar
      Merge pull request #137 from box/jwt_fixes · a1dba2d7
      Jordan Moldow authored
      Fixes to JWTAuth
      a1dba2d7
    • Jordan Moldow's avatar
      Fixes to JWTAuth · 1d1559a7
      Jordan Moldow authored
      Open the PEM private key file in 'rb' mode so that `.read()`
      returns `bytes` in Python 3. Otherwise, the default openssl
      backend of cryptography fails to use the key.
      
      Set the `_user_id` attribute to `None` when authenticating an
      enterprise instance.
      
      Fixes #136.
      1d1559a7
  16. 19 May, 2016 1 commit
  17. 18 May, 2016 1 commit
    • Jordan Moldow's avatar
      Always update `OAuth2` object with new tokens · 7239ba71
      Jordan Moldow authored
      If the protected method `_get_tokens()` returns new tokens,
      refresh is skipped, and those tokens are used.
      
      Previously, we would return the new tokens without updating the
      object state. Subsequent uses of the `OAuth2` object would use
      the old tokens.
      
      Now we will correctly update the object state.
      
      Fixes #128.
      
      Also make some minor test fixes and upgrade the version of mock
      that we use.
      
      Prepare for bump to version 1.5.2.
      7239ba71
  18. 23 Mar, 2016 4 commits