def __init__(self, source_string='', mapping=None, __name__=''): DTMLDocument.__init__(self, source_string=source_string, mapping=mapping, __name__=__name__, ) ZwikiDublinCoreImpl.__init__(self)
def __init__(self, source_string='', mapping=None, __name__=''): DTMLDocument.__init__( self, source_string=source_string, mapping=mapping, __name__=__name__, ) ZwikiDublinCoreImpl.__init__(self)
def _createZODBClone(self): """ Create a ZODB (editable) equivalent of this object. """ if _STX_TEMPLATE == 'DTML': target = DTMLDocument(_CUSTOMIZED_TEMPLATE_DTML, __name__=self.getId()) elif _STX_TEMPLATE == 'ZPT': target = ZopePageTemplate(self.getId(), _CUSTOMIZED_TEMPLATE_ZPT) target._setProperty('stx', self.raw, 'text') return target
def _createZODBClone(self): """ Create a ZODB (editable) equivalent of this object. """ if _STX_TEMPLATE == 'DTML': target = DTMLDocument(_CUSTOMIZED_TEMPLATE_DTML, __name__=self.getId()) elif _STX_TEMPLATE == 'ZPT': target = ZopePageTemplate(self.getId(), _CUSTOMIZED_TEMPLATE_ZPT) target._setProperty('stx', self.raw, 'text') return target
def _createObjectByType( self, name, body, content_type ): if isinstance( body, unicode ): encoding = self.getEncoding() if encoding is None: body = body.encode() else: body = body.encode( encoding ) if name.endswith('.py'): ob = PythonScript( name ) ob.write( body ) elif name.endswith('.dtml'): ob = DTMLDocument( '', __name__=name ) ob.munge( body ) elif content_type in ('text/html', 'text/xml' ): ob = ZopePageTemplate( name, body , content_type=content_type ) elif content_type[:6]=='image/': ob=Image( name, '', body, content_type=content_type ) else: ob=File( name, '', body, content_type=content_type ) return ob
def generateERP5FormCSS(): parsed_scribus = self._getParsedScribusFile() import_pdf_file = StringIO.StringIO( self.getDefaultPdfFormValue().getData()) pdf_parser = PDFParser(import_pdf_file) import_scribus_file = StringIO.StringIO( self.getDefaultScribusFormValue().getData()) scribus_parser = ScribusParser(import_scribus_file) page_gap = scribus_parser.getPageGap() scribus_width = scribus_parser.getPageWidth() scribus_height = scribus_parser.getPageHeight() space_between_pages = 20 # XXX - hardcoded image0 = self.getERP5FormImage(0) properties_css_dict = getPropertiesCSSDict( parsed_scribus, page_gap, image0.getWidth(), image0.getHeight(), scribus_width, scribus_height, space_between_pages, self.getPortalObject().portal_preferences) # declaring object that holds the CSS data css_file_name = "%s_css.css" % self.getId().replace(' ', '') css_file_content = generateCSSOutputContent(properties_css_dict) css_file = DTMLDocument(css_file_content, __name__=css_file_name) import_scribus_file.close() import_pdf_file.close() return css_file
def _createObjectByType( self, name, body, content_type ): if name.endswith('.py'): ob = PythonScript( name ) ob.write( body ) elif name.endswith('.dtml'): ob = DTMLDocument( '', __name__=name ) ob.munge( body ) elif content_type in ('text/html', 'text/xml' ): ob = ZopePageTemplate( name, str( body ) , content_type=content_type ) elif content_type[:6]=='image/': ob=Image( name, '', body, content_type=content_type ) else: ob=File( name, '', body, content_type=content_type ) return ob
def _createObjectByType(self, name, body, content_type): encoding = self.getEncoding() or 'utf-8' if six.PY2 and isinstance(body, six.text_type): body = body.encode(encoding) if name.endswith('.py'): ob = PythonScript(name) ob.write(body) return ob if name.endswith('.dtml'): ob = DTMLDocument('', __name__=name) ob.munge(body) return ob if content_type in ('text/html', 'text/xml'): return ZopePageTemplate(name, body, content_type=content_type) if isinstance(body, six.text_type): body = body.encode(encoding) if content_type[:6] == 'image/': return Image(name, '', body, content_type=content_type) return File(name, '', body, content_type=content_type)
def _default_PUT_factory(self, name, typ, body): # Return DTMLDoc/PageTemplate/Image/File, based on sniffing. if name and name.endswith('.pt'): ob = ZopePageTemplate(name, body, content_type=typ) elif typ in ('text/html', 'text/xml', 'text/plain'): ob = DTMLDocument('', __name__=name) elif typ[:6] == 'image/': ob = Image(name, '', body, content_type=typ) else: ob = File(name, '', body, content_type=typ) return ob
def _default_PUT_factory(self, name, typ, body): # See if the name contains a file extension shortname, ext = os.path.splitext(name) # Make sure the body is bytes if not isinstance(body, bytes): body = body.encode('UTF-8') if ext == '.dtml': ob = DTMLDocument('', __name__=name) elif typ in ('text/html', 'text/xml'): ob = ZopePageTemplate(name, body, content_type=typ) elif typ[:6] == 'image/': ob = Image(name, '', body, content_type=typ) else: ob = File(name, '', body, content_type=typ) return ob