thirdparty/google_appengine/google/appengine/ext/db/djangoforms.py
changeset 828 f5fd65cc3bf3
parent 109 620f9b141567
child 2413 d0b7dac5325c
--- a/thirdparty/google_appengine/google/appengine/ext/db/djangoforms.py	Tue Jan 20 01:12:43 2009 +0000
+++ b/thirdparty/google_appengine/google/appengine/ext/db/djangoforms.py	Tue Jan 20 13:19:45 2009 +0000
@@ -22,6 +22,10 @@
 db package instead, and create Django forms from it, either fully
 automatically, or with overrides.
 
+Note, you should not import these classes from this module.  Importing
+this module patches the classes in place, and you should continue to
+import them from google.appengine.db.
+
 Some of the code here is strongly inspired by Django's own ModelForm
 class (new in Django 0.97).  Our code also supports Django 0.96 (so as
 to be maximally compatible).  Note that our API is always similar to
@@ -76,6 +80,7 @@
 
 
 import itertools
+import logging
 
 
 import django.core.exceptions
@@ -208,6 +213,15 @@
     return value
 
 
+class UserProperty(db.Property):
+  """This class exists solely to log a warning when it is used."""
+
+  def __init__(self, *args, **kwds):
+    logging.warn("Please don't use modelforms.UserProperty; "
+                 "use db.UserProperty instead.")
+    super(UserProperty, self).__init__(*args, **kwds)
+
+
 class StringProperty(db.StringProperty):
   __metaclass__ = monkey_patch
 
@@ -376,20 +390,6 @@
     return bool(value)
 
 
-class UserProperty(db.UserProperty):
-  __metaclass__ = monkey_patch
-
-  def get_form_field(self, **kwargs):
-    """Return a Django form field appropriate for a user property.
-
-    This defaults to a CharField whose initial value is the current
-    username.
-    """
-    defaults = {'initial': users.GetCurrentUser()}
-    defaults.update(kwargs)
-    return super(UserProperty, self).get_form_field(**defaults)
-
-
 class StringListProperty(db.StringListProperty):
   __metaclass__ = monkey_patch