Python google.appengine.ext.db.BlobProperty() Examples

The following are 6 code examples of google.appengine.ext.db.BlobProperty(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module google.appengine.ext.db , or try the search function .
Example #1
Source File: db.py    From jbox with MIT License 5 votes vote down vote up
def convert_BlobProperty(model, prop, kwargs):
    """Returns a form field for a ``db.BlobProperty``."""
    return f.FileField(**kwargs) 
Example #2
Source File: db.py    From RSSNewsGAE with Apache License 2.0 5 votes vote down vote up
def convert_BlobProperty(model, prop, kwargs):
    """Returns a form field for a ``db.BlobProperty``."""
    return f.FileField(**kwargs) 
Example #3
Source File: db.py    From googleapps-message-recall with Apache License 2.0 5 votes vote down vote up
def convert_BlobProperty(model, prop, kwargs):
    """Returns a form field for a ``db.BlobProperty``."""
    return f.FileField(**kwargs) 
Example #4
Source File: djangoforms.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
    super(BlobProperty, self).__init__(*args, **kwargs)
    self.form_value = None 
Example #5
Source File: djangoforms.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for a blob property.

    This defaults to a forms.FileField instance when using Django 0.97
    or later.  For 0.96 this returns None, as file uploads are not
    really supported in that version.
    """
    if not hasattr(forms, 'FileField'):
      return None
    defaults = {'form_class': forms.FileField}
    defaults.update(kwargs)
    return super(BlobProperty, self).get_form_field(**defaults) 
Example #6
Source File: djangoforms.py    From python-compat-runtime with Apache License 2.0 5 votes vote down vote up
def make_value_from_form(self, value):
    """Convert a form value to a property value.

    This extracts the content from the UploadedFile instance returned
    by the FileField instance.
    """
    if have_uploadedfile and isinstance(value, uploadedfile.UploadedFile):
      if not self.form_value:
        self.form_value = value.read()
      b = db.Blob(self.form_value)
      return b
    return super(BlobProperty, self).make_value_from_form(value)