Skip to content

Commit

Permalink
changed is valid to is ready (compatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 15, 2015
1 parent 14d4b3a commit 27ffcb4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
21 changes: 16 additions & 5 deletions data/src/entity_manager/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ class levels to find id.
# and then breaks the cycle
id = key
break

# in case the id is not defined in the current
# class need to find elsewhere in the upper (parent)
# class chain
Expand All @@ -2066,7 +2066,7 @@ class levels to find id.
# value meaning that no id value exists for it
parent = cls.get_parent()
if not parent: return None

# runs the recursive step of retrieving the id
# value from the parent class (default behavior)
id = parent.get_id()
Expand Down Expand Up @@ -2318,12 +2318,23 @@ def has_parents(cls, abstract_valid = False):
# available
cls._has_parents = True
return True

@classmethod
def is_valid(cls):
def is_ready(cls):
"""
Verifies if the current entity class is ready to be used
in a persistent context. Some entity classes may not comply
with all the requirements for the persistence and are considered
not ready/available for the persistence context.
@rtype: bool
@return: If the current entity class is ready and available
for the current persistence context.
"""

table_id = cls.get_id()
if table_id == None: return False
return True
return True

@classmethod
def is_abstract(cls):
Expand Down
26 changes: 13 additions & 13 deletions data/src/entity_manager/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,10 +1256,10 @@ def ensure_definition(self, entity_class):
# returns immediately no need to
# create the definition
return
# in case the provided entity class is not valid, missing

# in case the provided entity class is not ready, missing
# values or not ready for persistence, must return immediately
if not entity_class.is_valid():
if not entity_class.is_ready():
# returns immediately no need to
# create the definition
return
Expand All @@ -1284,10 +1284,10 @@ def create_relations(self, entity_class):
@param entity_class: The entity class to be used in he creation
of the indirect relations associative tables.
"""
# in case the provided entity class is not valid, missing

# in case the provided entity class is not ready, missing
# values or not ready for persistence, must return immediately
if not entity_class.is_valid(): return
if not entity_class.is_ready(): return

# retrieves the ensure integrity option that should "request"
# if a data source level integrity must be done or if the data
Expand Down Expand Up @@ -1757,9 +1757,9 @@ def increment_id(self, name):
return next_id

def create_definition(self, entity_class):
# in case the provided entity class is not valid, missing
# in case the provided entity class is not ready, missing
# values or not ready for persistence, must return immediately
if not entity_class.is_valid(): return
if not entity_class.is_ready(): return

# generates the create definition query, general
# sql query for the current context and then
Expand All @@ -1771,20 +1771,20 @@ def create_definition(self, entity_class):
self.execute_query(index_queries)

def delete_definition(self, entity_class):
# in case the provided entity class is not valid, missing
# in case the provided entity class is not ready, missing
# values or not ready for persistence, must return immediately
if not entity_class.is_valid(): return
if not entity_class.is_ready(): return

# generates the delete definition query, general
# sql query for the current context and then
# executes it in the appropriate engine
query = self._delete_definition_query(entity_class)
self.execute_query(query)

def sync_entity_definition(self, entity_class):
# in case the provided entity class is not valid, missing
# in case the provided entity class is not ready, missing
# values or not ready for persistence, must return immediately
if not entity_class.is_valid(): return
if not entity_class.is_ready(): return

def enable(self, entity):
# retrieves the entity class associated with the
Expand Down

0 comments on commit 27ffcb4

Please sign in to comment.