I've read the documentation at South and I would really like to take
this opportunity to say this project would be way better with improved
documentation or maybe I'm just missing something. I recently added a
new model to my project which is using South, which means syndcb no
longer simply adds the model to the database.   So Now I'm faced with
these errors regarding my custom ProtectedFileField for generating
time-expiry links, therefore I followed the instructions adding this
code to my fields.py :

from south.modelsinspector import add_introspection_rules

# We need to add introspection rules to our custom fields for south to
function properly.
add_introspection_rules([], ["^student_portal\.fields
\.ProtectedFileField"])

def gen_sec_link(rel_path):
    """
    Generate a temporary authorized link to download a file @param
rel_path.
    This function is used with Apache mod_auth_token to serve up
secure content.

    """
    secret = settings.AUTH_TOKEN_PASSWORD
    uri_prefix = '/media/uploads/'
    rel_path = rel_path[7:]
    hextime = "%08x" % time.time()
    token = hashlib.md5(secret + rel_path + hextime).hexdigest()
    return '%s%s/%s%s' % (uri_prefix, token, hextime, rel_path)
# EndDef

class ProtectedFieldFile(FieldFile):
    """
    This subclass of FieldFile (which is FileField's underlying
storage class)
    overrides the url API method to implement mod_auth_token secure
links for all ProtectedFileFields.
    Reason this is great: it fixes all broken links in applications
that use this models.file_field.url and
        allows the template language to be simplified and less prone
to errors.

    """
    def _get_url(self):
        self._require_file()
        return gen_sec_link(self.name)
    url = property(_get_url)
# EndClass

class ProtectedFileField(FileField):
    """
    This class class is the model field label you would declare in
models.py

    """
    attr_class = ProtectedFieldFile
    description = ugettext_lazy("File path with Auth_Token support.")


I've added the south specific code to models.py, __init__.py and as
mentioned fields.py.

from south.modelsinspector import add_introspection_rules

# We need to add introspection rules to our custom fields for south to
function properly.
add_introspection_rules([], ["^student_portal\.fields
\.ProtectedFileField"])

but still get the error:

matteius@classcomm-dev:/var/django_projects/classcomm$ sudo python
manage.py schemamigration classcomm.student_portal
auto_add_extra_credit --add-model ExtraCredit
 ! Cannot freeze field 'student_portal.assignment.provided_files'
 ! (this field has class
classcomm.student_portal.fields.ProtectedFileField)
 ! Cannot freeze field 'student_portal.grade.returned_files'
 ! (this field has class
classcomm.student_portal.fields.ProtectedFileField)
 ! Cannot freeze field 'student_portal.submission.file'
 ! (this field has class
classcomm.student_portal.fields.ProtectedFileField)

 ! South cannot introspect some fields; this is probably because they
are custom
 ! fields. If they worked in 0.6 or below, this is because we have
removed the
 ! models parser (it often broke things).
 ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork


By far the main blocking point of my day and finishing adding this
ExtraCredit model to my project.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to