-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client functions in v6.0.0 do not work - HTTP Client Object has no attribute insert_permission
#1385
Comments
@Joangaes, sorry for taking advantage of your issue, but I had a similar problem so I'll just add it here. It was with the export function. Traceback (most recent call last):
File "xxx.py", line xxx, in <module>
export_file = workbook.export(format=ExportFormat.EXCEL)
File "/home/xxx/oss/changehistory/venv/lib/python3.8/site-packages/gspread/spreadsheet.py", line 518, in export
return self.client.export(self.id, format)
AttributeError: 'HTTPClient' object has no attribute 'export' Here's what I've tried: import gspread
gc = gspread.service_account()
sh = gc.open("XXX").export() |
Hi, thanks for the issue :) This seems to be a big problem with the new release. For now I would consider using the latest version v5.12.4 until this is fixed, with pip install gspread==5.12.4 InformationI am not sure what the problem is, but I provide relevant parts of code for v5 and v6 v5 (old, working)class Client:
def __init__(self, auth, session=None):
if auth is not None:
self.auth = convert_credentials(auth)
self.session = session or AuthorizedSession(self.auth)
else:
self.session = session
self.timeout = None
def open(self, title, folder_id=None):
spreadsheet_files, response = self._list_spreadsheet_files(title, folder_id)
try:
properties = finditem(
lambda x: x["name"] == title,
spreadsheet_files,
)
except StopIteration as ex:
raise SpreadsheetNotFound(response) from ex
# Drive uses different terminology
properties["title"] = properties["name"]
return Spreadsheet(self, properties)
class Spreadsheet:
def __init__(self, client, properties):
self.client = client
...
def export(self, format=ExportFormat.PDF):
return self.client.export(self.id, format) v6 (new, broken)class Client:
def __init__(
self, auth: Credentials, http_client: HTTPClientType = HTTPClient
) -> None:
self.http_client = http_client(auth)
def open(self, title: str, folder_id: Optional[str] = None) -> Spreadsheet:
spreadsheet_files, response = self._list_spreadsheet_files(title, folder_id)
try:
properties = finditem(
lambda x: x["name"] == title,
spreadsheet_files,
)
except StopIteration as ex:
raise SpreadsheetNotFound(response) from ex
# Drive uses different terminology
properties["title"] = properties["name"]
return Spreadsheet(self.http_client, properties)
class Spreadsheet:
def __init__(self, http_client, properties):
self.client = http_client
...
def export(self, format=ExportFormat.PDF):
return self.client.export(self.id, format) I must go now but the investigation can be continued from here. Looks like a problem with what is passed to the |
HTTP Client Object has no attribute insert_permission
@lavigne958 you assign me but I do not know much about the |
I saw your first investigation I thought you wanted to continue when you have time. I think we can provide a fix for both issues that just raised and then release 6.0.1 with both fixes, you agree ? |
I went through the list of missing actions it seems the new HTTP client is missing the bellow actions:
I will fix that soon (in a couple of days at most) and make the next fixup release 6.0.1 thank you everyone for helping. |
See burnash/gspread#1385 (written 30.01.2024 1:45)
The `HTTPClient` class was missing the `export` method. Add it in order for the gspread `Client` and the `Spreadsheet` class to use it to export spreadsheets. closes #1385 Signed-off-by: Alexandre Lavigne <[email protected]>
Add missing methods to the HTTP client. update code so the gspread Client and the spreadsheet use these new methods in order to: - insert - list - remove a permission. We can't test these function automatically as this requires exposing personal information in the recorded requests. We'll add more tests later when we find a way. closes #1385 Signed-off-by: Alexandre Lavigne <[email protected]>
Important: Please do not post usage questions here.
To get a quick response, please ask a question on Stack Overflow using
gspread
tag.See existing questions: https://stackoverflow.com/questions/tagged/gspread
Describe the bug
When we are sharing a spreadsheet there is an issue with Sharing since the HTTPClient doesn't have the insert_permission function.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
We should be able to share stuff.
The text was updated successfully, but these errors were encountered: