Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
    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 _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)