Change the context on-the-fly of the Model class (keyspace, connection)
(self, keyspace=None, connection=None)
| 1025 | return clone |
| 1026 | |
| 1027 | def using(self, keyspace=None, connection=None): |
| 1028 | """ |
| 1029 | Change the context on-the-fly of the Model class (keyspace, connection) |
| 1030 | """ |
| 1031 | |
| 1032 | if connection and self._batch: |
| 1033 | raise CQLEngineException("Cannot specify a connection on model in batch mode.") |
| 1034 | |
| 1035 | clone = copy.deepcopy(self) |
| 1036 | if keyspace: |
| 1037 | from cassandra.cqlengine.models import _clone_model_class |
| 1038 | clone.model = _clone_model_class(self.model, {'__keyspace__': keyspace}) |
| 1039 | |
| 1040 | if connection: |
| 1041 | clone._connection = connection |
| 1042 | |
| 1043 | return clone |
| 1044 | |
| 1045 | |
| 1046 | class ResultObject(dict): |