Skip to content

PYTHON-649#677

Merged
mambocab merged 13 commits into
apache:masterfrom
mambocab:PYTHON-649
Dec 19, 2016
Merged

PYTHON-649#677
mambocab merged 13 commits into
apache:masterfrom
mambocab:PYTHON-649

Conversation

@mambocab
Copy link
Copy Markdown
Contributor

I don't necessarily expect this to get merged as-is; this is more of a review request. I want to check:

  • that others like the for user_type, conn in product(set(udts), connection._connections.values()) approach
  • that the tests in tests/integration/cqlengine/model/test_udts.py cover the cases we care about, in terms of ordering UDT definitions and connection creations. I think they have, but I'd like a review and to have another look myself.

Comment thread cassandra/cqlengine/models.py Outdated
for user_type in set(udts):
user_type.register_for_keyspace(klass._get_keyspace())
for user_type, conn in product(set(udts), connection._connections.values()):
user_type.register_for_keyspace(klass._get_keyspace(), connection=conn)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would probably work. However, It might be better to keep the 'connection' logic only in the management commands. I think It will become confusing if we start adding some of that logic in different places. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean -- let me have a look at what consolidating the logic would involve.

@mambocab
Copy link
Copy Markdown
Contributor Author

Pushed 5c649a9; rebasing for a cleaner history.

@mambocab mambocab force-pushed the PYTHON-649 branch 4 times, most recently from c4f9989 to ae28fb2 Compare November 22, 2016 22:58
@mambocab
Copy link
Copy Markdown
Contributor Author

I've pushed a new test for behavior that was broken with #656, and a fix for that. I think there's definitely some code dedupe to be done here before merge.

Comment thread cassandra/cqlengine/connection.py Outdated
default_name = 'default'
conn = Connection.from_session(default_name, s)
_connections[default_name] = conn
set_default_connection[default_name]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to work as expected. I'm getting this exception:

    connection.set_session(s)
  File "/home/aboudreault/dev/python-driver/cassandra/cqlengine/connection.py", line 238, in set_session
    set_default_connection[default_name]
TypeError: 'function' object has no attribute '__getitem__'

You probably want to do set_default_connection(...).

@mambocab
Copy link
Copy Markdown
Contributor Author

Fixed the set_default_connection call; not sure how I missed that.

Unit tests now pass locally. Do you agree that it's worth the time to refactor before we commit? I don't like the duplication between register_connection and set_session -- it's only a couple lines, but I think they're likely to change relatively soon.

@aboudreault
Copy link
Copy Markdown
Contributor

aboudreault commented Nov 28, 2016

+1

I agree that set_session could be removed in the next major release. register_connection should be able to register a new connection from a session object. I don't have any objection if we can add that support now (if it's easy) but we need to keep set_session. You can add a note about the the removal of it in https://datastax-oss.atlassian.net/browse/PYTHON-504

@mambocab mambocab force-pushed the PYTHON-649 branch 2 times, most recently from b86ba06 to 70eddcf Compare November 29, 2016 22:53
@aboudreault
Copy link
Copy Markdown
Contributor

Looks good. it might be good to add some documentation about that, with 2 examples, and also specifying what configuration arguments are incompatible with the session param.

@aboudreault
Copy link
Copy Markdown
Contributor

+1

@mambocab mambocab merged commit 2e28fc2 into apache:master Dec 19, 2016
@mambocab mambocab deleted the PYTHON-649 branch December 19, 2016 15:48
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.

2 participants