from Products.PythonScripts.PythonScript import PythonScript
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from OFS.DTMLDocument import DTMLDocument
from OFS.Image import Image
from OFS.Image import File


def PUT_factory( self, name, typ, body ):
    # Gimme a PageTemplate or a PythonScript, but never DTML!
    if typ=='text/x-python' or (body and body[0]=='#'):
        ob = PythonScript( name )
    elif typ.startswith('text'):
        ob = ZopePageTemplate(name, body, content_type='text/html')
    elif typ.startswith('image/'):
        ob = Image(name, '', body, content_type=typ)
    else:
        ob = File(name, '', body, content_type=typ)
    return ob


