Skip to content

Commit

Permalink
exposing is_null
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfalcao committed Sep 6, 2015
1 parent 6fae135 commit 4394b7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions repocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from repocket.connections import configure
from repocket.model import ActiveRecord
from repocket.manager import ActiveRecordManager
from repocket.util import is_null

__all__ = [
'attributes',
'configure',
'ActiveRecord',
'ActiveRecordManager',
'MODELS',
'is_null',
]
12 changes: 1 addition & 11 deletions repocket/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from decimal import Decimal as PythonsDecimal

from repocket._cache import MODELS

from repocket.util import is_null

logger = logging.getLogger("repocket.attributes")

Expand All @@ -20,16 +20,6 @@ def get_current_time(field):
return datetime.utcnow()


def is_null(value):
if not value:
return True

if isinstance(value, basestring) and value.lower() in ['none', json.dumps(None)]:
return True

return False


class Attribute(object):
"""Repocket treats its models and attributes as fully serializable.
Every attribute contains a ``to_python`` method that knows how to
Expand Down
8 changes: 8 additions & 0 deletions repocket/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def is_null(value):
if value is None:
return True

if isinstance(value, basestring) and value.lower() in ['null', 'none']:
return True

return False

0 comments on commit 4394b7f

Please sign in to comment.