Back to index

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

List of all members.

Public Member Functions

def CookedBody
def EditableBody
def setFormat
def setText
def guessMimetypeOfText
def getTidyOutput
def manage_afterAdd
def cmf_edit
def manage_afterPUT

Static Public Attributes

 schema = ATDocumentSchema
string portal_type = 'Document'
string archetype_name = 'Page'
tuple assocMimetypes = ('application/xhtml+xml', 'message/rfc822', 'text/*',)
tuple assocFileExt = ('txt', 'stx', 'rst', 'rest', 'py',)
tuple security = ClassSecurityInfo()
tuple cmf_edit_kws = ('text_format',)
tuple text_format = ComputedAttribute(ATCTContent.getContentType, 1)

Static Private Attributes

dictionary _atct_newTypeFor = {'portal_type' : 'CMF Document', 'meta_type' : 'Document'}
 __implements__ = ATDocumentBase.__implements__,IATDocument

Detailed Description

A page in the site. Can contain rich text.

Definition at line 273 of file document.py.


Member Function Documentation

def ATContentTypes.content.document.ATDocumentBase.cmf_edit (   self,
  text_format,
  text,
  file = '',
  safety_belt = '',
  kwargs 
) [inherited]

Definition at line 243 of file document.py.

00243 
00244     def cmf_edit(self, text_format, text, file='', safety_belt='', **kwargs):
00245         assert file == '', 'file currently not supported' # XXX
00246         self.setText(text, mimetype=translateMimetypeAlias(text_format))
00247         self.update(**kwargs)

def ATContentTypes.content.document.ATDocumentBase.CookedBody (   self,
  stx_level = 'ignored' 
) [inherited]
CMF compatibility method

Definition at line 118 of file document.py.

00118 
00119     def CookedBody(self, stx_level='ignored'):
00120         """CMF compatibility method
00121         """
00122         return self.getText()
00123 

Here is the call graph for this function:

CMF compatibility method

Definition at line 125 of file document.py.

00125 
00126     def EditableBody(self):
00127         """CMF compatibility method
00128         """
00129         return self.getRawText()

Here is the caller graph for this function:

def ATContentTypes.content.document.ATDocumentBase.getTidyOutput (   self,
  field 
) [inherited]
Get the tidied output for a specific field from the request
if available

Definition at line 204 of file document.py.

00204 
00205     def getTidyOutput(self, field):
00206         """Get the tidied output for a specific field from the request
00207         if available
00208         """
00209         request = getattr(self, 'REQUEST', None)
00210         if request is not None and isinstance(request, HTTPRequest):
00211             tidyAttribute = '%s_tidier_data' % field.getName()
00212             return request.get(tidyAttribute, None)

Here is the caller graph for this function:

For ftp/webdav upload: get the mimetype from the id and data

Definition at line 181 of file document.py.

00181 
00182     def guessMimetypeOfText(self):
00183         """For ftp/webdav upload: get the mimetype from the id and data
00184         """
00185         mtr  = getToolByName(self, 'mimetypes_registry')
00186         id   = self.getId()
00187         data = self.getRawText()
00188         ext  = id.split('.')[-1]
00189 
00190         if ext != id:
00191             mimetype = mtr.classify(data, filename=ext)
00192         else:
00193             # no extension
00194             mimetype = mtr.classify(data)
00195 
00196         if not mimetype or (type(mimetype) is TupleType and not len(mimetype)):
00197             # nothing found
00198             return None
00199 
00200         if type(mimetype) is TupleType and len(mimetype):
00201             mimetype = mimetype[0]
00202         return mimetype.normalized()

Here is the caller graph for this function:

def ATContentTypes.content.document.ATDocumentBase.manage_afterAdd (   self,
  item,
  container 
) [inherited]
Fix text when created througt webdav
Guess the right mimetype from the id/data

Definition at line 222 of file document.py.

00222 
00223     def manage_afterAdd(self, item, container):
00224         """Fix text when created througt webdav
00225         Guess the right mimetype from the id/data
00226         """
00227         ATCTContent.manage_afterAdd(self, item, container)
00228         field = self.getField('text')
00229 
00230         # hook for mxTidy / isTidyHtmlWithCleanup validator
00231         tidyOutput = self.getTidyOutput(field)
00232         if tidyOutput:
00233             if hasattr(self, '_v_renamed'):
00234                 mimetype = field.getContentType(self)
00235                 del self._v_renamed
00236             else:
00237                 mimetype = self.guessMimetypeOfText()
00238             if mimetype:
00239                 field.set(self, tidyOutput, mimetype=mimetype) # set is ok
00240             elif tidyOutput:
00241                 field.set(self, tidyOutput) # set is ok

Here is the call graph for this function:

def ATContentTypes.content.document.ATDocumentBase.manage_afterPUT (   self,
  data,
  marshall_data,
  file,
  context,
  mimetype,
  filename,
  REQUEST,
  RESPONSE 
) [inherited]
After webdav/ftp PUT method

Set title according to the id on webdav/ftp PUTs.

Definition at line 250 of file document.py.

00250 
00251                         filename, REQUEST, RESPONSE):
00252         """After webdav/ftp PUT method
00253 
00254         Set title according to the id on webdav/ftp PUTs.
00255         """
00256 
00257         if '' == data:
00258             file.seek(0)
00259             content = file.read(65536)
00260         else:
00261             content = data
00262 
00263         if -1 != content.lower().find("<html"):
00264             parser = SimpleHTMLParser()
00265             parser.feed(content)
00266             if parser.title:
00267                 self.setTitle(parser.title)
00268             return
00269 
00270         ATCTContent.manage_afterPUT(self, data, marshall_data, file,
00271                                     context, mimetype, filename, REQUEST,
00272                                     RESPONSE)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.document.ATDocumentBase.setFormat (   self,
  value 
) [inherited]
CMF compatibility method

The default mutator is overwritten to:

  o add a conversion from stupid CMF content type (e.g. structured-text)
    to real mime types used by MTR.

  o Set format to default format if value is empty

Definition at line 132 of file document.py.

00132 
00133     def setFormat(self, value):
00134         """CMF compatibility method
00135         
00136         The default mutator is overwritten to:
00137         
00138           o add a conversion from stupid CMF content type (e.g. structured-text)
00139             to real mime types used by MTR.
00140         
00141           o Set format to default format if value is empty
00142 
00143         """
00144         if not value:
00145             value = zconf.ATDocument.default_content_type
00146         else:
00147             value = translateMimetypeAlias(value)
00148         ATCTContent.setFormat(self, value)

Here is the call graph for this function:

Here is the caller graph for this function:

def ATContentTypes.content.document.ATDocumentBase.setText (   self,
  value,
  kwargs 
) [inherited]
Body text mutator

* hook into mxTidy an replace the value with the tidied value

Definition at line 150 of file document.py.

00150 
00151     def setText(self, value, **kwargs):
00152         """Body text mutator
00153         
00154         * hook into mxTidy an replace the value with the tidied value
00155         """
00156         field = self.getField('text')
00157         # XXX this is ugly
00158         # When an object is initialized the first time we have to 
00159         # set the filename and mimetype.
00160         # In the case the value is empty/None we must not set the value because
00161         # it will overwrite uploaded data like a pdf file.
00162         if (value is None or value == ""):
00163             if not field.getRaw(self):
00164                 # set mimetype and file name although the fi
00165                 if 'mimetype' in kwargs and kwargs['mimetype']:
00166                     field.setContentType(self, kwargs['mimetype'])
00167                 if 'filename' in kwargs and kwargs['filename']:
00168                     field.setFilename(self, kwargs['filename'])
00169             else:
00170                 return
00171 
00172         # hook for mxTidy / isTidyHtmlWithCleanup validator
00173         tidyOutput = self.getTidyOutput(field)
00174         if tidyOutput:
00175             value = tidyOutput
00176 
00177         field.set(self, value, **kwargs) # set is ok

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from ATContentTypes.content.document.ATDocumentBase.

Definition at line 284 of file document.py.

dictionary ATContentTypes.content.document.ATDocument._atct_newTypeFor = {'portal_type' : 'CMF Document', 'meta_type' : 'Document'} [static, private]

Definition at line 280 of file document.py.

Definition at line 279 of file document.py.

tuple ATContentTypes.content.document.ATDocument.assocFileExt = ('txt', 'stx', 'rst', 'rest', 'py',) [static]

Definition at line 282 of file document.py.

tuple ATContentTypes.content.document.ATDocument.assocMimetypes = ('application/xhtml+xml', 'message/rfc822', 'text/*',) [static]

Definition at line 281 of file document.py.

Definition at line 115 of file document.py.

Definition at line 278 of file document.py.

Definition at line 276 of file document.py.

tuple ATContentTypes.content.document.ATDocumentBase.security = ClassSecurityInfo() [static, inherited]

Definition at line 114 of file document.py.

tuple ATContentTypes.content.document.ATDocumentBase.text_format = ComputedAttribute(ATCTContent.getContentType, 1) [static, inherited]

Definition at line 178 of file document.py.


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