8000 Implemented ConnectionParser to handle Federated and Legacy connections by t8y8 · Pull Request #7 · tableau/document-api-python · GitHub
[go: up one dir, main page]

Skip to content

Implemented ConnectionParser to handle Federated and Legacy connections #7

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

Merged
merged 3 commits into from
May 16, 2016
Merged

Implemented ConnectionParser to handle Federated and Legacy connections #7

merged 3 commits into from
May 16, 2016

Conversation

t8y8
Copy link
Contributor
@t8y8 t8y8 commented May 13, 2016

Here is one approach I thought of to deal with v10 workbooks and legacy workbooks.

The idea is to hide all the connection parsing away from the Datasource class.

I have a few questions and would love a second opinion.

DO NOT MERGE THIS. Feedback only :)

Tests do pass, though ConnectionParser doesn't have any of its own yet.
Added a v10 workbook to the tests. TODO: Cleanup the file handling

Addresses #5

Subsumed by later comments

t8y8 added 2 commits May 12, 2016 21:11
…o get all connection elements (that matter) and return them as a list. This is 'functional' and doesn't break old style connections. I'm going to try something in a different PR that might be a better approach
…t. I'm not sure if I like this approach or not.
if float(self._dsversion) < 10:
connections = self._extract_legacy_connection()
else:
connections = self._extract_federated_connections()
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'm beginning to wonder if we shouldn't have a different class for the NamedConnection that just mimics the old interface, but can handle things like the caption and other attributes that legacy connections don't have.

But that might be more than we need right now

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 spoke to Sundeep, and he confirmed I can ignore the named-connection elements for Server purposes.

Copy link

Choose a reason for hiding this comment

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

Fine for now. In the end, we should have separate classes for parsing 10.0+ vs prior connections. This current format, I think, will lead to potentially a good number of if else cases. I think there can be inheritance. Just a note for going forward. For now ... I wouldn't bother.

…for now. Also added the ConnectionParser tests and added it to the __init__ file to make it importable. There are probaly redundant tests now, but they're still less than a second so oh well for now. ConnectionParser is responsible for extracting the connection elements from the Datasource XML. I'm debating making the interface consistent so that ._connection always returns a list, even if it's just one element... That can be another checkin
@t8y8 t8y8 changed the title PROTOTYPE: Implemented ConnectionParser to handle Federated and Legacy connections Implemented ConnectionParser to handle Federated and Legacy connections May 13, 2016
@t8y8 t8y8 self-assigned this May 14, 2016
@@ -28,7 +47,8 @@ def __init__(self, dsxml, filename=None):
self._datasourceTree = ET.ElementTree(self._datasourceXML)
self._name = self._datasourceXML.get('name') or self._datasourceXML.get('formatted-name') # TDS files don't have a name attribute
self._version = self._datasourceXML.get('version')
self._connection = Connection(self._datasourceXML.find('connection'))
self._connection_parser = ConnectionParser(self._datasourceXML, version=self._version)
self._connection = self._connection_parser.get_connections()
Copy link

Choose a reason for hiding this comment

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

If we are returning a list, connection needs to be plural (same for the accessor)

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 breaks the existing API, but that's probably ok because only the sample needs to be updated :)

@benlower and I discussed always returning a list for connections, even in the legacy case, what do you think? I have that change shelved already and can add it to the PR.

Copy link

Choose a reason for hiding this comment

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

The "existing" api doesn't exist yet. :) I think we are okay for just a bit longer and then will have to worry about versioining and such but (a) we are still in BETA and (b) we haven't even released the BETA. :)

And I am good with returning a list even for older datasources. Consistent API. I don't want users having to put if cases for version numbers.

@benlower
Copy link
Contributor

Merging this. Opened two issues related to this: #9 #8

@benlower benlower merged commit a22d077 into tableau:master May 16, 2016
@benlower benlower deleted the connection-parser branch May 16, 2016 18:22
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
0