Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
CMFDefault.File.File Class Reference
Inheritance diagram for CMFDefault.File.File:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.File.File:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def id
def SearchableText
def edit
def index_html
def download
def Format
def setFormat
def PUT

Public Attributes

 precondition

Static Public Attributes

 effective_date = expiration_dateNone
 icon = PortalContent.icon
tuple manage_options
tuple security = ClassSecurityInfo()

Private Member Functions

def _isNotEmpty
def _edit
def _setOldCacheHeaders

Static Private Attributes

tuple __implements__

Detailed Description

A Portal-managed File.

Definition at line 80 of file File.py.


Constructor & Destructor Documentation

def CMFDefault.File.File.__init__ (   self,
  id,
  title = '',
  file = '',
  content_type = '',
  precondition = '',
  subject = (),
  description = '',
  contributors = (),
  effective_date = None,
  expiration_date = None,
  format = None,
  language = 'en-US',
  rights = '' 
)

Definition at line 113 of file File.py.

00113 
00114                 ):
00115         OFS.Image.File.__init__( self, id, title, file
00116                                , content_type, precondition )
00117         self._setId(id)
00118         delattr(self, '__name__')
00119 
00120         # If no file format has been passed in, rely on what OFS.Image.File
00121         # detected. Unlike Images, which have code to try and pick the content
00122         # type out of the binary data, File objects only provide the correct
00123         # type if a "hint" in the form of a filename extension is given.
00124         if format is None:
00125             format = self.content_type 
00126 
00127         DefaultDublinCoreImpl.__init__( self, title, subject, description
00128                                , contributors, effective_date, expiration_date
00129                                , format, language, rights )

Here is the call graph for this function:


Member Function Documentation

def CMFDefault.File.File._edit (   self,
  precondition = '',
  file = '' 
) [private]
Perform changes for user 

Definition at line 163 of file File.py.

00163 
00164     def _edit(self, precondition='', file=''):
00165         """ Perform changes for user """
00166         if precondition: self.precondition = precondition
00167         elif self.precondition: del self.precondition
00168 
00169         if self._isNotEmpty(file):
00170             self.manage_upload(file)

Here is the caller graph for this function:

def CMFDefault.File.File._isNotEmpty (   self,
  file 
) [private]
Do various checks on 'file' to try to determine non emptiness. 

Definition at line 145 of file File.py.

00145 
00146     def _isNotEmpty(self, file):
00147         """ Do various checks on 'file' to try to determine non emptiness. """
00148         if not file:
00149             return 0                    # Catches None, Missing.Value, ''
00150         elif file and (type(file) is type('')):
00151             return 1
00152         elif getattr(file, 'filename', None):
00153             return 1
00154         elif not hasattr(file, 'read'):
00155             return 0
00156         else:
00157             file.seek(0,2)              # 0 bytes back from end of file
00158             t = file.tell()             # Report the location
00159             file.seek(0)                # and return pointer back to 0
00160             if t: return 1
00161             else: return 0

def CMFDefault.File.File._setOldCacheHeaders (   self) [private]

Definition at line 212 of file File.py.

00212 
00213     def _setOldCacheHeaders(self):
00214         # return False to disable this simple caching behaviour
00215         return _OldCacheHeaders(self) 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.File.File.download (   self,
  REQUEST,
  RESPONSE 
)
Download this item.

Calls OFS.Image.File.index_html to perform the actual transfer after
first setting Content-Disposition to suggest a filename.

This method is deprecated, use the URL of this object itself. Because
the default view of a File object is to download, rather than view,
this method is obsolete. Also note that certain browsers do not deal
well with a Content-Disposition header.

Definition at line 217 of file File.py.

00217 
00218     def download(self, REQUEST, RESPONSE):
00219         """Download this item.
00220 
00221         Calls OFS.Image.File.index_html to perform the actual transfer after
00222         first setting Content-Disposition to suggest a filename.
00223 
00224         This method is deprecated, use the URL of this object itself. Because
00225         the default view of a File object is to download, rather than view,
00226         this method is obsolete. Also note that certain browsers do not deal
00227         well with a Content-Disposition header.
00228 
00229         """
00230 
00231         RESPONSE.setHeader('Content-Disposition',
00232                            'attachment; filename=%s' % self.getId())
00233         return self.index_html(self, REQUEST, RESPONSE)

def CMFDefault.File.File.edit (   self,
  precondition = '',
  file = '' 
)
Update and reindex. 

Definition at line 172 of file File.py.

00172 
00173     def edit(self, precondition='', file=''):
00174         """ Update and reindex. """
00175         self._edit( precondition, file )
00176         self.reindexObject()

Here is the call graph for this function:

Here is the caller graph for this function:

Dublin Core element - resource format 

Definition at line 235 of file File.py.

00235 
00236     def Format(self):
00237         """ Dublin Core element - resource format """
00238         return self.content_type

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.File.File.id (   self)

Definition at line 133 of file File.py.

00133 
00134     def id(self):
00135         return self.__name__

Here is the caller graph for this function:

def CMFDefault.File.File.index_html (   self,
  REQUEST,
  RESPONSE 
)
The default view of the contents of a File or Image.

Returns the contents of the file or image.  Also, sets the
Content-Type HTTP header to the objects content type.

Definition at line 178 of file File.py.

00178 
00179     def index_html(self, REQUEST, RESPONSE):
00180         """
00181         The default view of the contents of a File or Image.
00182 
00183         Returns the contents of the file or image.  Also, sets the
00184         Content-Type HTTP header to the objects content type.
00185         """
00186         view = _ViewEmulator().__of__(self)
00187 
00188         # If we have a conditional get, set status 304 and return
00189         # no content 
00190         if _checkConditionalGET(view, extra_context={}):
00191             return ''
00192 
00193         RESPONSE.setHeader('Content-Type', self.content_type)
00194 
00195         # old-style If-Modified-Since header handling.
00196         if self._setOldCacheHeaders():
00197             # Make sure the CachingPolicyManager gets a go as well
00198             _setCacheHeaders(view, extra_context={})
00199             return ''
00200 
00201         rendered = OFS.Image.File.index_html(self, REQUEST, RESPONSE)
00202 
00203         # There are 2 Cache Managers which can be in play....
00204         # need to decide which to use to determine where the cache headers
00205         # are decided on.
00206         if self.ZCacheable_getManager() is not None:
00207             self.ZCacheable_set(None)
00208         else:
00209             _setCacheHeaders(view, extra_context={})
00210 
00211         return rendered

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.File.File.PUT (   self,
  REQUEST,
  RESPONSE 
)
Handle HTTP (and presumably FTP?) PUT requests 

Definition at line 245 of file File.py.

00245 
00246     def PUT(self, REQUEST, RESPONSE):
00247         """ Handle HTTP (and presumably FTP?) PUT requests """
00248         OFS.Image.File.PUT( self, REQUEST, RESPONSE )
00249         self.reindexObject()
00250 
00251 InitializeClass(File)

Here is the call graph for this function:

SeachableText is used for full text seraches of a portal.  It
should return a concatenation of all useful text.

Definition at line 137 of file File.py.

00137 
00138     def SearchableText(self):
00139         """
00140         SeachableText is used for full text seraches of a portal.  It
00141         should return a concatenation of all useful text.
00142         """
00143         return "%s %s" % (self.title, self.description)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFDefault.File.File.setFormat (   self,
  format 
)
Dublin Core element - resource format 

Definition at line 240 of file File.py.

00240 
00241     def setFormat(self, format):
00242         """ Dublin Core element - resource format """
00243         self.manage_changeProperties(content_type=format)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple CMFDefault.File.File.__implements__ [static, private]
Initial value:
( PortalContent.__implements__
                     , DefaultDublinCoreImpl.__implements__
                     )

Definition at line 86 of file File.py.

CMFDefault.File.File.effective_date = expiration_dateNone [static]

Definition at line 90 of file File.py.

CMFDefault.File.File.icon = PortalContent.icon [static]

Definition at line 91 of file File.py.

Initial value:
( PortalContent.manage_options
                     + Cacheable.manage_options
                     )

Definition at line 93 of file File.py.

Definition at line 165 of file File.py.

tuple CMFDefault.File.File.security = ClassSecurityInfo() [static]

Definition at line 97 of file File.py.


The documentation for this class was generated from the following file: