|
6 | 6 | from morango.constants import transfer_statuses |
7 | 7 | from morango.registry import session_middleware |
8 | 8 | from morango.sync.operations import _deserialize_from_store |
9 | | -from morango.sync.operations import _serialize_into_store |
10 | 9 | from morango.sync.operations import OperationLogger |
| 10 | +from morango.sync.stream.serialize import serialize_into_store |
11 | 11 | from morango.sync.utils import SyncSignalGroup |
12 | 12 | from morango.utils import _assert |
13 | 13 |
|
14 | | - |
15 | 14 | logger = logging.getLogger(__name__) |
16 | 15 |
|
17 | 16 |
|
18 | | -def _self_referential_fk(klass_model): |
19 | | - """ |
20 | | - Return whether this model has a self ref FK, and the name for the field |
21 | | - """ |
22 | | - for f in klass_model._meta.concrete_fields: |
23 | | - if f.related_model: |
24 | | - if issubclass(klass_model, f.related_model): |
25 | | - return f.attname |
26 | | - return None |
27 | | - |
28 | | - |
29 | 17 | class MorangoProfileController(object): |
30 | 18 | def __init__(self, profile): |
31 | 19 | _assert(profile, "profile needs to be defined.") |
32 | 20 | self.profile = profile |
33 | 21 |
|
34 | | - def serialize_into_store(self, filter=None): |
| 22 | + def serialize_into_store(self, sync_filter=None): |
35 | 23 | """ |
36 | 24 | Takes data from app layer and serializes the models into the store. |
37 | 25 | """ |
38 | 26 | with OperationLogger("Serializing records", "Serialization complete"): |
39 | | - _serialize_into_store(self.profile, filter=filter) |
| 27 | + serialize_into_store(self.profile, sync_filter=sync_filter) |
40 | 28 |
|
41 | | - def deserialize_from_store(self, skip_erroring=False, filter=None): |
| 29 | + def deserialize_from_store(self, skip_erroring=False, sync_filter=None): |
42 | 30 | """ |
43 | 31 | Takes data from the store and integrates into the application. |
44 | 32 | """ |
45 | 33 | with OperationLogger("Deserializing records", "Deserialization complete"): |
46 | 34 | # we first serialize to avoid deserialization merge conflicts |
47 | | - _serialize_into_store(self.profile, filter=filter) |
| 35 | + serialize_into_store(self.profile, sync_filter=sync_filter) |
48 | 36 | _deserialize_from_store( |
49 | | - self.profile, filter=filter, skip_erroring=skip_erroring |
| 37 | + self.profile, filter=sync_filter, skip_erroring=skip_erroring |
50 | 38 | ) |
51 | 39 |
|
52 | 40 | def create_network_connection(self, base_url, **kwargs): |
@@ -217,7 +205,7 @@ def proceed_to_and_wait_for( |
217 | 205 | if tries >= max_interval_tries: |
218 | 206 | sleep(max_interval) |
219 | 207 | else: |
220 | | - sleep(0.3 * (2 ** tries - 1)) |
| 208 | + sleep(0.3 * (2**tries - 1)) |
221 | 209 | result = self.proceed_to(target_stage, context=context) |
222 | 210 | tries += 1 |
223 | 211 | if callable(callback): |
|
0 commit comments