Skip to content

194 fix namespace issue#219

Merged
graysonarts merged 21 commits intotableau:developmentfrom
graysonarts:194-fix-namespace-issue
Sep 15, 2017
Merged

194 fix namespace issue#219
graysonarts merged 21 commits intotableau:developmentfrom
graysonarts:194-fix-namespace-issue

Conversation

@graysonarts
Copy link
Contributor

Introduce detection of namespace url for backwards compatibility.

@graysonarts graysonarts requested review from LGraber and t8y8 September 13, 2017 18:44
if self._detected:
return

lines = (n for n in xml.split('\n') if n.startswith('<tsResponse'))
Copy link
Collaborator

@t8y8 t8y8 Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's breaks all ova' them tests because of str/bytes stuff.

I think we can reduce the parsing overhead a bit as well, by parsing the namespace outta the root element.

Something like this:

>>> root = ET.fromstring(server_response.content)
>>> root.tag
'{http://tableau.com/api}tsResponse'

And then run the find over just that smaller string:

re.findall(r'\{.*\}', root.tag)
>>> ['{http://tableau.com/api}']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm. Weird, I even tested wth python 3.6 on my mac. yeah I think I like this solution better.

parameters['data'] = content

server_response = method(url, **parameters)
self.parent_srv._namespace.detect(server_response.content)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the first request, of any kind, checks and caches itself, then we shortcut on subsequent requests.

I like the deisgn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. I think the only place where we might get in trouble is if the first request isn't the use server version workflow. At this point, I want to make that the default behavior. @LGraber any objections to always determining the server version to help solve this issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it be a problem if that wasn't the first call? I am not sure I see how this only happens on the first call?

def baseurl(self):
return "{0}/api/{1}".format(self._server_address, str(self.version))

@property
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 'xml_namespace' a better name? (No strong opinion here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt anyone outside of TSC contributors will use that property. I don't have a strong opinion either way.

Copy link
Collaborator

@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels SO GOOD to remove that giant package global from all those imports.

It's actually now trivial to officially support back to 9.0

EDIT: Ok, it's not trivial, since some very convenient features were added in 10 (like get workbooks). We could shim some of those but maybe it's not worth it. Still, I love this, it's so much cleaner for the future.

matches = NAMESPACE_RE.match(root.tag)
if matches:
detected_ns = matches.group(1)
if detected_ns in (OLD_NAMESPACE, NEW_NAMESPACE):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't throw here if we don't know what it is? Won't we fail in an odd way later?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not every request necessarily returns xml (deletes for example).

This just skips it an checks on the next request. Once it succeeds we cache the result and don't check again.

We default to the new namespace so nothing should fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no real reason. I'll add a new exception

from .. import ConnectionItem, DatasourceItem,\
GroupItem, PaginationItem, ProjectItem, ScheduleItem, SiteItem, TableauAuth,\
UserItem, ViewItem, WorkbookItem, TaskItem, NAMESPACE
UserItem, ViewItem, WorkbookItem, TaskItem, namespace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this the only one lowercase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should have been removed. It's not needed anymore

Copy link
Collaborator

@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@LGraber
Copy link
Contributor

LGraber commented Sep 15, 2017

🚀

@graysonarts graysonarts merged commit ff60613 into tableau:development Sep 15, 2017
@graysonarts graysonarts deleted the 194-fix-namespace-issue branch September 15, 2017 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants