Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Static Private Attributes
ATContentTypes.content.file.ATFile Class Reference
Inheritance diagram for ATContentTypes.content.file.ATFile:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.content.file.ATFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def index_html
def setFile
def __str__
def getIcon
def icon
def txng_get
def cmf_edit

Static Public Attributes

 schema = ATFileSchema
string portal_type = 'File'
string archetype_name = 'File'
tuple assocMimetypes = ('application/*', 'audio/*', 'video/*', )
tuple assocFileExt = ()
tuple cmf_edit_kws = ()
tuple inlineMimetypes
tuple security = ClassSecurityInfo()

Static Private Attributes

dictionary _atct_newTypeFor = {'portal_type' : 'CMF File', 'meta_type' : 'Portal File'}
 __implements__ = ATCTFileContent.__implements__,IATFile

Detailed Description

An external file uploaded to the site.

Definition at line 85 of file file.py.


Member Function Documentation

cmf compatibility

Definition at line 126 of file file.py.

00126 
00127     def __str__(self):
00128         """cmf compatibility
00129         """
00130         return self.get_data()

Here is the call graph for this function:

def ATContentTypes.content.file.ATFile.cmf_edit (   self,
  precondition = '',
  file = None 
)

Definition at line 211 of file file.py.

00211 
00212     def cmf_edit(self, precondition='', file=None):
00213         if file is not None:
00214             self.setFile(file)
00215 
00216 registerATCT(ATFile, PROJECTNAME)

Here is the call graph for this function:

def ATContentTypes.content.file.ATFile.getIcon (   self,
  relative_to_portal = 0 
)
Calculate the icon using the mime type of the file

Definition at line 132 of file file.py.

00132 
00133     def getIcon(self, relative_to_portal=0):
00134         """Calculate the icon using the mime type of the file
00135         """
00136         field = self.getField('file')
00137         if not field or not self.get_size():
00138             # field is empty
00139             return BaseContent.getIcon(self, relative_to_portal)
00140 
00141         contenttype       = field.getContentType(self)
00142         contenttype_major = contenttype and contenttype.split('/')[0] or ''
00143 
00144         mtr   = getToolByName(self, 'mimetypes_registry', None)
00145         utool = getToolByName( self, 'portal_url' )
00146 
00147         if ICONMAP.has_key(contenttype):
00148             icon = quote(ICONMAP[contenttype])
00149         elif ICONMAP.has_key(contenttype_major):
00150             icon = quote(ICONMAP[contenttype_major])
00151         else:
00152             mimetypeitem = None
00153             try:
00154                 mimetypeitem = mtr.lookup(contenttype)
00155             except MimeTypeException, msg:
00156                 LOG.error('MimeTypeException for %s. Error is: %s' % (self.absolute_url(), str(msg)))
00157             if not mimetypeitem:
00158                 return BaseContent.getIcon(self, relative_to_portal)
00159             icon = mimetypeitem[0].icon_path
00160 
00161         if relative_to_portal:
00162             return icon
00163         else:
00164             # Relative to REQUEST['BASEPATH1']
00165             res = utool(relative=1) + '/' + icon
00166             while res[:1] == '/':
00167                 res = res[1:]
00168             return res

Here is the call graph for this function:

Here is the caller graph for this function:

for ZMI

Definition at line 170 of file file.py.

00170 
00171     def icon(self):
00172         """for ZMI
00173         """
00174         return self.getIcon()

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.file.ATFile.index_html (   self,
  REQUEST = None,
  RESPONSE = None 
)
Download the file

Definition at line 107 of file file.py.

00107 
00108     def index_html(self, REQUEST=None, RESPONSE=None):
00109         """Download the file
00110         """
00111         field = self.getPrimaryField()
00112 
00113         if field.getContentType(self) in self.inlineMimetypes:
00114             # return the PDF and Office file formats inline
00115             return ATCTFileContent.index_html(self, REQUEST, RESPONSE)
00116         # otherwise return the content as an attachment 
00117         # Please note that text/* cannot be returned inline as
00118         # this is a security risk (IE renders anything as HTML).
00119         return field.download(self)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.file.ATFile.setFile (   self,
  value,
  kwargs 
)
Set id to uploaded id

Definition at line 121 of file file.py.

00121 
00122     def setFile(self, value, **kwargs):
00123         """Set id to uploaded id
00124         """
00125         self._setATCTFileContent(value, **kwargs)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.file.ATFile.txng_get (   self,
  attr = ('SearchableText', 
)
Special searchable text source for text index ng 2

Definition at line 176 of file file.py.

00176 
00177     def txng_get(self, attr=('SearchableText',)):
00178         """Special searchable text source for text index ng 2
00179         """
00180         if attr[0] != 'SearchableText':
00181             # only a hook for searchable text
00182             return
00183 
00184         source   = ''
00185         mimetype = 'text/plain'
00186         encoding = 'utf-8'
00187 
00188         # stage 1: get the searchable text and convert it to utf8
00189         sp    = getToolByName(self, 'portal_properties').site_properties
00190         stEnc = getattr(sp, 'default_charset', 'utf-8')
00191         st    = self.SearchableText()
00192         source+=unicode(st, stEnc).encode('utf-8')
00193 
00194         # get the file and try to convert it to utf8 text
00195         ptTool = getToolByName(self, 'portal_transforms')
00196         f  = self.getFile()
00197         if f:
00198             mt = f.getContentType()
00199             try:
00200                 result = ptTool.convertTo('text/plain', str(f), mimetype=mt)
00201                 if result:
00202                     data = result.getData()
00203                 else:
00204                     data = ''
00205             except TransformException:
00206                 data = ''
00207             source+=data
00208 
00209         return source, mimetype, encoding

Here is the call graph for this function:


Member Data Documentation

ATContentTypes.content.file.ATFile.__implements__ = ATCTFileContent.__implements__,IATFile [static, private]

Definition at line 102 of file file.py.

dictionary ATContentTypes.content.file.ATFile._atct_newTypeFor = {'portal_type' : 'CMF File', 'meta_type' : 'Portal File'} [static, private]

Definition at line 92 of file file.py.

Definition at line 91 of file file.py.

Definition at line 94 of file file.py.

tuple ATContentTypes.content.file.ATFile.assocMimetypes = ('application/*', 'audio/*', 'video/*', ) [static]

Definition at line 93 of file file.py.

Definition at line 95 of file file.py.

Initial value:
('application/msword',
                      'application/x-msexcel', # ?
                      'application/vnd.ms-excel',
                      'application/vnd.ms-powerpoint',
                      'application/pdf')

Definition at line 96 of file file.py.

Definition at line 90 of file file.py.

Definition at line 88 of file file.py.

tuple ATContentTypes.content.file.ATFile.security = ClassSecurityInfo() [static]

Definition at line 104 of file file.py.


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