1717class ShopifyConnection (pyactiveresource .connection .Connection ):
1818 response = None
1919
20- def __init__ (self , site , user = None , password = None , timeout = None ,
21- format = formats .JSONFormat ):
20+ def __init__ (self , site , user = None , password = None , timeout = None , format = formats .JSONFormat ):
2221 super (ShopifyConnection , self ).__init__ (site , user , password , timeout , format )
2322
2423 def _open (self , * args , ** kwargs ):
@@ -30,11 +29,11 @@ def _open(self, *args, **kwargs):
3029 raise
3130 return self .response
3231
32+
3333# Inherit from pyactiveresource's metaclass in order to use ShopifyConnection
3434
3535
3636class ShopifyResourceMeta (ResourceMeta ):
37-
3837 @property
3938 def connection (cls ):
4039 """HTTP connection for the current thread"""
@@ -51,8 +50,7 @@ def connection(cls):
5150 local .url = cls .url
5251 if cls .site is None :
5352 raise ValueError ("No shopify session is active" )
54- local .connection = ShopifyConnection (
55- cls .site , cls .user , cls .password , cls .timeout , cls .format )
53+ local .connection = ShopifyConnection (cls .site , cls .user , cls .password , cls .timeout , cls .format )
5654 return local .connection
5755
5856 def get_user (cls ):
@@ -62,8 +60,7 @@ def set_user(cls, value):
6260 cls ._threadlocal .connection = None
6361 ShopifyResource ._user = cls ._threadlocal .user = value
6462
65- user = property (get_user , set_user , None ,
66- "The username for HTTP Basic Auth." )
63+ user = property (get_user , set_user , None , "The username for HTTP Basic Auth." )
6764
6865 def get_password (cls ):
6966 return getattr (cls ._threadlocal , 'password' , ShopifyResource ._password )
@@ -72,8 +69,7 @@ def set_password(cls, value):
7269 cls ._threadlocal .connection = None
7370 ShopifyResource ._password = cls ._threadlocal .password = value
7471
75- password = property (get_password , set_password , None ,
76- "The password for HTTP Basic Auth." )
72+ password = property (get_password , set_password , None , "The password for HTTP Basic Auth." )
7773
7874 def get_site (cls ):
7975 return getattr (cls ._threadlocal , 'site' , ShopifyResource ._site )
@@ -93,8 +89,7 @@ def set_site(cls, value):
9389 if parts .password :
9490 cls .password = urllib .parse .unquote (parts .password )
9591
96- site = property (get_site , set_site , None ,
97- 'The base REST site to connect to.' )
92+ site = property (get_site , set_site , None , 'The base REST site to connect to.' )
9893
9994 def get_timeout (cls ):
10095 return getattr (cls ._threadlocal , 'timeout' , ShopifyResource ._timeout )
@@ -103,8 +98,7 @@ def set_timeout(cls, value):
10398 cls ._threadlocal .connection = None
10499 ShopifyResource ._timeout = cls ._threadlocal .timeout = value
105100
106- timeout = property (get_timeout , set_timeout , None ,
107- 'Socket timeout for HTTP requests' )
101+ timeout = property (get_timeout , set_timeout , None , 'Socket timeout for HTTP requests' )
108102
109103 def get_headers (cls ):
110104 if not hasattr (cls ._threadlocal , 'headers' ):
@@ -114,8 +108,7 @@ def get_headers(cls):
114108 def set_headers (cls , value ):
115109 cls ._threadlocal .headers = value
116110
117- headers = property (get_headers , set_headers , None ,
118- 'The headers sent with HTTP requests' )
111+ headers = property (get_headers , set_headers , None , 'The headers sent with HTTP requests' )
119112
120113 def get_format (cls ):
121114 return getattr (cls ._threadlocal , 'format' , ShopifyResource ._format )
@@ -124,8 +117,7 @@ def set_format(cls, value):
124117 cls ._threadlocal .connection = None
125118 ShopifyResource ._format = cls ._threadlocal .format = value
126119
127- format = property (get_format , set_format , None ,
128- 'Encoding used for request and responses' )
120+ format = property (get_format , set_format , None , 'Encoding used for request and responses' )
129121
130122 def get_prefix_source (cls ):
131123 """Return the prefix source, by default derived from site."""
@@ -141,8 +133,7 @@ def set_prefix_source(cls, value):
141133 """Set the prefix source, which will be rendered into the prefix."""
142134 cls ._prefix_source = value
143135
144- prefix_source = property (get_prefix_source , set_prefix_source , None ,
145- 'prefix for lookups for this type of object.' )
136+ prefix_source = property (get_prefix_source , set_prefix_source , None , 'prefix for lookups for this type of object.' )
146137
147138 def get_version (cls ):
148139 if hasattr (cls ._threadlocal , 'version' ) or ShopifyResource ._version :
@@ -153,25 +144,22 @@ def get_version(cls):
153144 def set_version (cls , value ):
154145 ShopifyResource ._version = cls ._threadlocal .version = value
155146
156- version = property (get_version , set_version , None ,
157- 'Shopify Api Version' )
147+ version = property (get_version , set_version , None , 'Shopify Api Version' )
158148
159149 def get_url (cls ):
160150 return getattr (cls ._threadlocal , 'url' , ShopifyResource ._url )
161151
162152 def set_url (cls , value ):
163153 ShopifyResource ._url = cls ._threadlocal .url = value
164154
165- url = property (get_url , set_url , None ,
166- 'Base URL including protocol and shopify domain' )
155+ url = property (get_url , set_url , None , 'Base URL including protocol and shopify domain' )
167156
168157
169158@six .add_metaclass (ShopifyResourceMeta )
170159class ShopifyResource (ActiveResource , mixins .Countable ):
171160 _format = formats .JSONFormat
172161 _threadlocal = threading .local ()
173- _headers = {
174- 'User-Agent' : 'ShopifyPythonAPI/%s Python/%s' % (shopify .VERSION , sys .version .split (' ' , 1 )[0 ])}
162+ _headers = {'User-Agent' : 'ShopifyPythonAPI/%s Python/%s' % (shopify .VERSION , sys .version .split (' ' , 1 )[0 ])}
175163 _version = None
176164 _url = None
177165
0 commit comments