text
stringlengths
0
828
(data) = cls._empty_with_http_info(**kwargs)
return data"
4724,"def get(cls, **kwargs):
""""""Get cart.
Retrieve the shopping cart of the current session.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.get(async=True)
>>> result = thread.get()
:param async bool
:return: ShoppingCart
If the method is called asynchronously,
returns the request thread.
""""""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return cls._get_with_http_info(**kwargs)
else:
(data) = cls._get_with_http_info(**kwargs)
return data"
4725,"def update_item(cls, item_id, item, **kwargs):
""""""Update cart.
Update cart item.
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.update_item(item_id, item, async=True)
>>> result = thread.get()
:param async bool
:param str item_id: Item ID to update. (required)
:param LineItem item: Line item to update. (required)
:return: ShoppingCart
If the method is called asynchronously,
returns the request thread.
""""""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
return cls._update_item_with_http_info(item_id, item, **kwargs)
else:
(data) = cls._update_item_with_http_info(item_id, item, **kwargs)
return data"
4726,"def get_perm_names(cls, resource):
"""""" Return all permissions supported by the resource.
This is used for auto-generating missing permissions rows into
database in syncdb.
""""""
return [cls.get_perm_name(resource, method) for method in cls.METHODS]"
4727,"def get_perm_name(cls, resource, method):
"""""" Compose permission name
@param resource the resource
@param method the request method (case doesn't matter).
""""""
return '%s_%s_%s' % (
cls.PREFIX,
cls._get_resource_name(resource),
method.lower())"
4728,"def check_perm(self, request, resource):
"""""" Check permission
@param request the HTTP request
@param resource the requested resource
@raise Forbidden if the user doesn't have access to the resource
""""""
perm_name = self.get_perm_name(resource, request.method)
if not self._has_perm(request.user, perm_name):
raise errors.Forbidden()"
4729,"def _has_perm(self, user, permission):
"""""" Check whether the user has the given permission
@return True if user is granted with access, False if not.
""""""
if user.is_superuser:
return True
if user.is_active:
perms = [perm.split('.')[1] for perm in user.get_all_permissions()]
return permission in perms
return False"
4730,"def wash_url_argument(var, new_type):
""""""
Wash argument into 'new_type', that can be 'list', 'str',
'int', 'tuple' or 'dict'.
If needed, the check 'type(var) is not None' should be done before
calling this function.
@param var: variable value
@param new_type: variable type, 'list', 'str', 'int', 'tuple' or 'dict'
@return: as much as possible, value var as type new_type
If var is a list, will change first element into new_type.
If int check unsuccessful, returns 0
""""""
out = []
if new_type == 'list': # return lst