Skip to content

Commit dad00ee

Browse files
committed
Update based on CR.
1 parent f351d3d commit dad00ee

21 files changed

+108
-101
lines changed

HISTORY.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ Release History
66
Upcoming
77
++++++++
88

9-
- Box objects have an improved ``__repr__``, making them easier to identify during debugging sessions.
10-
- Box objects now implement ``__dir__``, making them easier to explore. When created with a Box API response,
11-
these objects will now include the API response fields as attributes.
129

1310

14-
1.5.0 (2016-03-02)
11+
1.5.0 (2016-03-17)
1512
++++++++++++++++++
1613

1714
- Added a new class, ``LoggingClient``. It's a ``Client`` that uses the ``LoggingNetwork`` class so that
@@ -21,6 +18,9 @@ Upcoming
2118
- Made the ``oauth`` parameter to ``Client`` optional. The constructor now accepts new parameters that it will use
2219
to construct the ``OAuth2`` instance it needs to auth with the Box API.
2320
- Changed the default User Agent string sent with requests to the Box API. It is now 'box-python-sdk-<version>'.
21+
- Box objects have an improved ``__repr__``, making them easier to identify during debugging sessions.
22+
- Box objects now implement ``__dir__``, making them easier to explore. When created with a Box API response,
23+
these objects will now include the API response fields as attributes.
2424

2525

2626

README.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,19 @@ For more control over how the information is logged, use the ``LoggingNetwork``
377377
# Use a custom logger
378378
client = Client(oauth, network_layer=LoggingNetwork(logger))
379379
380+
Developer Token Client
381+
~~~~~~~~~~~~~~~~~~~~~~
382+
383+
The Box Developer Console allows for the creation of short-lived developer tokens. The SDK makes it easy to use these
384+
tokens. Use the ``get_new_token_callback`` parameter to control how the client will get new developer tokens as
385+
needed. The default is to prompt standard input for a token.
386+
380387
Development Client
381388
~~~~~~~~~~~~~~~~~~
382389

383390
For exploring the Box API, or to quickly get going using the SDK, the ``DevelopmentClient`` class combines the
384391
``LoggingClient`` with the ``DeveloperTokenClient``.
385392

386-
Developer Token Client
387-
~~~~~~~~~~~~~~~~~~~~~~
388-
389-
The Box Developer Console allows for the creation of short-lived developer tokens. The SDK makes it easy to use these
390-
tokens. Use the
391-
392393
Contributing
393394
------------
394395

boxsdk/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# coding: utf-8
22

3-
from __future__ import unicode_literals
3+
from __future__ import unicode_literals, absolute_import
44

55
from .auth import JWTAuth, OAuth2
66
from .client import * # pylint:disable=wildcard-import,redefined-builtin
77
from .object import * # pylint:disable=wildcard-import,redefined-builtin
8-
from .config import Version
9-
__version__ = Version.VERSION
8+
from .version import __version__

boxsdk/client/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@
44

55
from .client import Client
66
from .developer_token_client import DeveloperTokenClient
7+
from .development_client import DevelopmentClient
78
from .logging_client import LoggingClient
8-
9-
10-
class DevelopmentClient(DeveloperTokenClient, LoggingClient):
11-
"""
12-
Client subclass that uses developer token auth and logs requests and responses.
13-
Great for use in development!
14-
"""
15-
pass

boxsdk/client/client.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# coding: utf-8
22

3-
from __future__ import unicode_literals
3+
from __future__ import unicode_literals, absolute_import
44
import json
55

6-
from ..auth import OAuth2
76
from ..config import API
87
from ..session.box_session import BoxSession
98
from ..network.default_network import DefaultNetwork
@@ -16,7 +15,6 @@
1615
from ..object.group_membership import GroupMembership
1716
from ..util.shared_link import get_shared_link_header
1817
from ..util.translator import Translator
19-
from ..util.url import get_url
2018

2119

2220
class Client(object):
@@ -26,10 +24,6 @@ def __init__(
2624
oauth=None,
2725
network_layer=None,
2826
session=None,
29-
client_id=None,
30-
client_secret=None,
31-
store_tokens=None,
32-
**kwargs
3327
):
3428
"""
3529
:param oauth:
@@ -44,24 +38,9 @@ def __init__(
4438
The session object to use. If None is provided then an instance of :class:`BoxSession` will be used.
4539
:type session:
4640
:class:`BoxSession`
47-
:param client_id:
48-
Box API key used for identifying the application the user is authenticating with.
49-
Ignored if oauth instance is passed into this constructor.
50-
:type client_id:
51-
`unicode`
52-
:param client_secret:
53-
Box API secret used for making OAuth2 requests.
54-
Ignored if oauth instance is passed into this constructor.
55-
:type client_secret:
56-
`unicode`
57-
:param store_tokens:
58-
Optional callback for getting access to tokens for storing them.
59-
Ignored if oauth instance is passed into this constructor.
60-
:type store_tokens:
61-
`callable`
6241
"""
6342
network_layer = network_layer or DefaultNetwork()
64-
self._oauth = oauth or OAuth2(client_id, client_secret, store_tokens=store_tokens, **kwargs)
43+
self._oauth = oauth
6544
self._network = network_layer
6645
self._session = session or BoxSession(oauth=oauth, network_layer=network_layer)
6746

@@ -411,4 +390,4 @@ def get_url(self, endpoint, *args):
411390
`unicode`
412391
"""
413392
# pylint:disable=no-self-use
414-
return get_url(endpoint, *args)
393+
return self._session.get_url(endpoint, *args)

boxsdk/client/developer_token_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ class DeveloperTokenClient(Client):
1010
"""
1111
Box client subclass which authorizes with a developer token.
1212
"""
13-
def __init__(self, oauth=None, network_layer=None, session=None, **kwargs):
13+
def __init__(self, oauth=None, network_layer=None, session=None):
1414
super(DeveloperTokenClient, self).__init__(
1515
oauth=oauth or DeveloperTokenAuth(),
1616
network_layer=network_layer,
1717
session=session,
18-
**kwargs
1918
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# coding: utf-8
2+
3+
from __future__ import unicode_literals, absolute_import
4+
5+
from .developer_token_client import DeveloperTokenClient
6+
from .logging_client import LoggingClient
7+
8+
9+
class DevelopmentClient(DeveloperTokenClient, LoggingClient):
10+
"""
11+
Client subclass that uses developer token auth and logs requests and responses.
12+
Great for use in development!
13+
"""
14+
pass

boxsdk/client/logging_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ class LoggingClient(Client):
1010
"""
1111
Box client subclass which logs requests and responses.
1212
"""
13-
def __init__(self, oauth=None, network_layer=None, session=None, **kwargs):
13+
def __init__(self, oauth=None, network_layer=None, session=None):
1414
super(LoggingClient, self).__init__(
15-
oauth,
15+
oauth=oauth,
1616
network_layer=network_layer or LoggingNetwork(),
1717
session=session,
18-
**kwargs
1918
)

boxsdk/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# coding: utf-8
22

3-
from __future__ import unicode_literals
3+
from __future__ import unicode_literals, absolute_import
4+
5+
from . import version
46

57

68
class API(object):
@@ -11,7 +13,7 @@ class API(object):
1113
OAUTH2_AUTHORIZE_URL = 'https://app.box.com/api/oauth2/authorize' # <https://developers.box.com/docs/#oauth-2-authorize>
1214

1315

14-
class Version(object):
15-
"""Configuration object containing the package version and user agent string."""
16-
VERSION = '1.5.0'
16+
class Client(object):
17+
"""Configuration object containing the user agent string."""
18+
VERSION = version.__version__
1719
USER_AGENT_STRING = 'box-python-sdk-{0}'.format(VERSION)

boxsdk/object/base_endpoint.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import unicode_literals
44

5-
from boxsdk.util.url import get_url
6-
75

86
class BaseEndpoint(object):
97
"""A Box API endpoint."""
@@ -34,7 +32,7 @@ def get_url(self, endpoint, *args):
3432
`unicode`
3533
"""
3634
# pylint:disable=no-self-use
37-
return get_url(endpoint, *args)
35+
return self._session.get_url(endpoint, *args)
3836

3937
def as_user(self, user):
4038
"""

0 commit comments

Comments
 (0)