Skip to content

Commit 0fa709d

Browse files
committed
fix: remove vizHeight and vizWidth from ImageRequestOptions
Closes tableau#1564 Retrieving a view image does not support vizHeight and vizWidth serverside. Supporting it for images as well was a mistake.
1 parent 364f431 commit 0fa709d

File tree

1 file changed

+40
-52
lines changed

1 file changed

+40
-52
lines changed

tableauserverclient/server/request_options.py

+40-52
Original file line numberDiff line numberDiff line change
@@ -268,46 +268,6 @@ def _append_view_filters(self, params) -> None:
268268
params[name] = value
269269

270270

271-
class _ImagePDFCommonExportOptions(_DataExportOptions):
272-
def __init__(self, maxage=-1, viz_height=None, viz_width=None):
273-
super().__init__(maxage=maxage)
274-
self.viz_height = viz_height
275-
self.viz_width = viz_width
276-
277-
@property
278-
def viz_height(self):
279-
return self._viz_height
280-
281-
@viz_height.setter
282-
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
283-
def viz_height(self, value):
284-
self._viz_height = value
285-
286-
@property
287-
def viz_width(self):
288-
return self._viz_width
289-
290-
@viz_width.setter
291-
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
292-
def viz_width(self, value):
293-
self._viz_width = value
294-
295-
def get_query_params(self) -> dict:
296-
params = super().get_query_params()
297-
298-
# XOR. Either both are None or both are not None.
299-
if (self.viz_height is None) ^ (self.viz_width is None):
300-
raise ValueError("viz_height and viz_width must be specified together")
301-
302-
if self.viz_height is not None:
303-
params["vizHeight"] = self.viz_height
304-
305-
if self.viz_width is not None:
306-
params["vizWidth"] = self.viz_width
307-
308-
return params
309-
310-
311271
class CSVRequestOptions(_DataExportOptions):
312272
"""
313273
Options that can be used when exporting a view to CSV. Set the maxage to control the age of the data exported.
@@ -338,7 +298,7 @@ class ExcelRequestOptions(_DataExportOptions):
338298
extension = "xlsx"
339299

340300

341-
class ImageRequestOptions(_ImagePDFCommonExportOptions):
301+
class ImageRequestOptions(_DataExportOptions):
342302
"""
343303
Options that can be used when exporting a view to an image. Set the maxage to control the age of the data exported.
344304
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -354,13 +314,6 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
354314
maxage: int, optional
355315
The maximum age of the data to export. Shortest possible duration is 1
356316
minute. No upper limit. Default is -1, which means no limit.
357-
358-
viz_height: int, optional
359-
The height of the viz in pixels. If specified, viz_width must also be specified.
360-
361-
viz_width: int, optional
362-
The width of the viz in pixels. If specified, viz_height must also be specified.
363-
364317
"""
365318

366319
extension = "png"
@@ -369,8 +322,10 @@ class ImageRequestOptions(_ImagePDFCommonExportOptions):
369322
class Resolution:
370323
High = "high"
371324

372-
def __init__(self, imageresolution=None, maxage=-1, viz_height=None, viz_width=None):
373-
super().__init__(maxage=maxage, viz_height=viz_height, viz_width=viz_width)
325+
def __init__(self, imageresolution=None, maxage=-1):
326+
super().__init__(
327+
maxage=maxage,
328+
)
374329
self.image_resolution = imageresolution
375330

376331
def get_query_params(self):
@@ -380,7 +335,7 @@ def get_query_params(self):
380335
return params
381336

382337

383-
class PDFRequestOptions(_ImagePDFCommonExportOptions):
338+
class PDFRequestOptions(_DataExportOptions):
384339
"""
385340
Options that can be used when exporting a view to PDF. Set the maxage to control the age of the data exported.
386341
Filters to the underlying data can be applied using the `vf` and `parameter` methods.
@@ -425,12 +380,45 @@ class Orientation:
425380
Landscape = "landscape"
426381

427382
def __init__(self, page_type=None, orientation=None, maxage=-1, viz_height=None, viz_width=None):
428-
super().__init__(maxage=maxage, viz_height=viz_height, viz_width=viz_width)
383+
super().__init__(
384+
maxage=maxage,
385+
)
429386
self.page_type = page_type
430387
self.orientation = orientation
388+
self.viz_height = viz_height
389+
self.viz_width = viz_width
390+
391+
@property
392+
def viz_height(self):
393+
return self._viz_height
394+
395+
@viz_height.setter
396+
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
397+
def viz_height(self, value):
398+
self._viz_height = value
399+
400+
@property
401+
def viz_width(self):
402+
return self._viz_width
403+
404+
@viz_width.setter
405+
@property_is_int(range=(0, sys.maxsize), allowed=(None,))
406+
def viz_width(self, value):
407+
self._viz_width = value
431408

432409
def get_query_params(self) -> dict:
433410
params = super().get_query_params()
411+
412+
# XOR. Either both are None or both are not None.
413+
if (self.viz_height is None) ^ (self.viz_width is None):
414+
raise ValueError("viz_height and viz_width must be specified together")
415+
416+
if self.viz_height is not None:
417+
params["vizHeight"] = self.viz_height
418+
419+
if self.viz_width is not None:
420+
params["vizWidth"] = self.viz_width
421+
434422
if self.page_type:
435423
params["type"] = self.page_type
436424

0 commit comments

Comments
 (0)