GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Create New Connections per #68 by t8y8 · Pull Request #69 · tableau/document-api-python

Conversation

@t8y8

@t8y8 t8y8 commented Jul 30, 2016

Copy link
Copy Markdown
Contributor

This is all that we'd need for creating connections from scratch.

Authentication isn't validated right now so it's not very safe, it defaults to '' because I need to research more how this attribute works

Feedback:

  • Name. The issue proposes .create() but our current pattern is from_something
  • Approach -- though it's simple
  • Thoughts on authentication
  • Note I fixed a bug I introduced, the name of the dbclass in the xml is actually 'class'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@t8y8
First attempt
70771ff
t8y8
t8y8 reviewed Jul 30, 2016
View reviewed changes
Comment thread tableaudocumentapi/connection.py

self._class = value
self._connectionXML.set('dbclass', value)
self._connectionXML.set('class', value)

@t8y8 t8y8 Jul 30, 2016

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Totally a bug in my dbclass code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@t8y8
pep8, I'll add a precommit hook for myself
27dceea
@t8y8

t8y8 commented Jul 30, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Alright, I've totally got a prototype working for creating datasources (V10) as well. It's ugly but wanted to get it out for discussion.

    @classmethod
    def from_scratch(cls, caption, connections):
        from uuid import uuid4
        unique = lambda x: x + '.' + str(uuid4()).replace('-', '')[:28]
        root = ET.Element('datasource')
        root.set('caption', caption)
        root.set('version', '10.0')
        outer_connection = ET.SubElement(root, 'connection')
        outer_connection.set('class', 'federated')
        named_conns = ET.SubElement(outer_connection, 'named-connections')
        for conn in connections:
            nc = ET.SubElement(named_conns, 'named-connection')
            nc.set('name', unique(conn.dbclass))
            nc.append(conn._connectionXML)
        print(ET.tostring(root))
        return cls(root)

I don't actually know the rules for what makes a good 'name' -- it appears to be dbclass + a 28 character random string ('postgres.1of3kl00aoax5d1a1ejma1397430'), it's definitely not a UUID though

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t8y8
Protoype new datasource
557b9fe
@t8y8

t8y8 commented Aug 4, 2016

Copy link
Copy Markdown
Contributor Author

Alright, pushed my attempt.

@RussTheAerialist I'm not sure if it's overcomplicating things or not, but it feels like this logic could live in an, bleck, DatasourceBuilder, or something like that. It could take in a version parameter and know how to build 9.X vs 10.X as well.

Of course, none of that addresses the problem that these are 'bare' datasources without relations, metadata-records, or fields.

Thoughts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

graysonarts
graysonarts reviewed Aug 9, 2016
View reviewed changes
Comment thread tableaudocumentapi/datasource.py Outdated


def make_unique_name(dbclass):
rand_part = ''.join(random.choice(

@graysonarts graysonarts Aug 9, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Our unique names are a hash based on the current time, so we should probably do that rather than random data. I can find the relevant code if you need it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@t8y8 t8y8 Aug 9, 2016

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
t8y8 added 2 commits August 9, 2016 10:35
@t8y8
Enable save_as for new datasources and add a required attribute
69cfda6
@t8y8
Use UUID encoded in base36
81e2946
@graysonarts

graysonarts commented Aug 15, 2016

Copy link
Copy Markdown
Contributor

🚀 this will need to be changed once I get all of the editor+physical+logical splitting done but for now, yay!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t8y8

t8y8 commented Aug 15, 2016

Copy link
Copy Markdown
Contributor Author

Awesome! At least it'll let us play with some examples, and the tests will stay valid.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@t8y8
t8y8 merged commit 8b8f351 into tableau:development Aug 15, 2016
@t8y8
t8y8 deleted the 68-feature-create-connection branch August 15, 2016 23:08
@graysonarts graysonarts modified the milestone: 2016.08 release Aug 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2016.08 release (v0.3)

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@t8y8 @graysonarts
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.