Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntactic sugar classes for ancestor queries #38

Open
wants to merge 28 commits into
base: feature/ancestor-query-1.4
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fbcecf5
git ignore
aburgel Nov 26, 2011
f265731
appengine key and ancestor support
aburgel Nov 26, 2011
decfc12
fixes for non-primary GAEKeys
aburgel Nov 26, 2011
87a9f85
use id_or_name as string value
aburgel Nov 29, 2011
fd234e6
better value conversion to match str from GAEKey
aburgel Nov 29, 2011
150c915
test cases for different kinds of pk representations
aburgel Nov 29, 2011
29a1c62
fix cmp for GAEKey
aburgel Dec 6, 2011
1a1456a
merge upstream/develop
aburgel Dec 27, 2011
091b12c
use methods instead of properties for GAEKey fields
aburgel Dec 29, 2011
b5f126a
Merge branch 'develop' of git://github.com/django-nonrel/djangoappeng…
aburgel Dec 29, 2011
902c363
remove missed @property, update unit tests
aburgel Dec 29, 2011
6aa66b7
use real_key for serialization
aburgel Jan 25, 2012
216aa48
modify SqlInsertCompiler to handle bulk inserts
aburgel Mar 17, 2012
7df916e
remove usage of XMLField
aburgel Mar 17, 2012
8208067
repr method for GAEKey
aburgel Mar 17, 2012
2fc14a5
do not encode cursor if it doesnt exist
aburgel Mar 17, 2012
b23cc69
do not allow null primary keys, check for empty strings when creating…
aburgel Mar 18, 2012
cc73be7
merge develop branch
aburgel Mar 23, 2012
60e62a7
merge develop branch
aburgel Mar 23, 2012
6a10a9d
rewrite ancestor queries for type-conversion-refactor
aburgel Mar 23, 2012
d38742e
django 1.4 updates
aburgel Mar 23, 2012
7407854
DBKeyField is a special case for conversion
aburgel Apr 20, 2012
b77c183
add missing import
aburgel Apr 20, 2012
9be9b5f
dbkeyfield should not be forced to nullable
aburgel Apr 20, 2012
4c6ebdf
added make_key function to simplify created DbKeys from models
aburgel Apr 20, 2012
32d2e17
Merge commit '257e3390ab4768abbb6d82af6c16438cb9ede3cb' into django-1.4
May 22, 2012
13c8b64
Merge branch 'feature/ancestor-query-1.4' of git://github.com/django-…
May 23, 2012
a417ac0
Add some syntactic sugar classes for doing ancestor queries.
May 25, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better value conversion to match str from GAEKey
aburgel committed Nov 29, 2011
commit fd234e61812b45415fc4380ba5030498195f02c6
23 changes: 9 additions & 14 deletions fields.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.core.exceptions import ValidationError
from django.db import models
from google.appengine.api.datastore import Key, datastore_errors
from .models import GAEKey, GAEAncestorKey
@@ -52,22 +53,16 @@ def to_python(self, value):
try:
return GAEKey(real_key=Key(encoded=value))
except datastore_errors.BadKeyError:
pass
raise ValueError("this value is not allowed %s" % value)
return GAEKey(real_key=Key.from_path(self.model._meta.db_table, long(value)))
if isinstance(value, (int, long)):
return GAEKey(real_key=Key.from_path(self.model._meta.db_table, value))

raise ValidationError("GAEKeyField does not accept %s" % type(value))

def get_prep_value(self, value):
if value is None:
return None
if isinstance(value, Key):
return GAEKey(real_key=value)
if isinstance(value, basestring):
try:
return GAEKey(real_key=Key(encoded=value))
except datastore_errors.BadKeyError:
raise ValueError("this value is not allowed %s" % value)
if not isinstance(value, (GAEKey, GAEAncestorKey)):
raise ValueError('Must by type GAEKey, GAEAncestorKey, basestring. Not <%s>' % type(value))
return value
if isinstance(value, GAEAncestorKey):
return value
return self.to_python(value)

def formfield(self, **kwargs):
return None