I remember when I used to see web applications with forms that had up to ten file fields, you know, in case you wanted to be more productive and submit many files in the same post. I smile when I think about those forms, not just because they looked funny, what with the repeating vertically-stacked file inputs, but also because of the whole file upload concept. Beyond sharing images on social networks, the practical use of user-generated files on the web has it's limitations. Think about where most of our tools are located. We're generally not screaming for new desktop applications, unless we're part of a particular crowd — like developers, graphic designers, hardcore gamers. We need desktop applications for these purposes, and these applications deal with files. But the vast majority of internet use isn't to this degree of specialization. What use does the general internet population have for file?
Showing posts with label file. Show all posts
Showing posts with label file. Show all posts
Thursday, December 20, 2012
Friday, September 11, 2009
Django Content Files
The Django web application framework written in Python defines a file abstraction used for working with files within the file system. Web applications often have to deal with many very different file formats. These aren't just static files that get served to the client using the system, they are also used to parse and retrieve useful file metadata. An example of this useful metadata would be the image dimensions of an image file. There is other useful file metadata that the clients of the system may not necessarily be concerned with although the system may be.
The File class is the base Django file abstraction. Instances of this class extend the concept of file-like objects in regular Python applications. This abstraction comes in handy when iterating through file contents. Django as a certain iteration style used throughout the framework and this abstraction helps maintain it. The File class is also helpful when dealing with images; it is the base class of the ImageFile class.
Code in Django applications can remain consistent with the file abstraction even when using regular content. Similar to how StringIO works. The ContentFile class inherits from the File class and ContentFile instances and behave just like File instances do. The main difference of course being that the ContentFile only uses raw data instead of data that lives on the file system. This gives Django a huge interface consistency boost when dealing with string data.
The File class is the base Django file abstraction. Instances of this class extend the concept of file-like objects in regular Python applications. This abstraction comes in handy when iterating through file contents. Django as a certain iteration style used throughout the framework and this abstraction helps maintain it. The File class is also helpful when dealing with images; it is the base class of the ImageFile class.
Code in Django applications can remain consistent with the file abstraction even when using regular content. Similar to how StringIO works. The ContentFile class inherits from the File class and ContentFile instances and behave just like File instances do. The main difference of course being that the ContentFile only uses raw data instead of data that lives on the file system. This gives Django a huge interface consistency boost when dealing with string data.
Labels:
content
,
django
,
file
,
python
,
webapplication
,
webframework
Subscribe to:
Posts
(
Atom
)