[Zope] PUT_Factory question
Andreas Wandel
wandel@math.uni-potsdam.de
Wed, 10 Oct 2001 23:54:37 +0200
Geir B=E6kholt wrote:
> =
> Hello Thierry,
> =
> Monday, October 08, 2001, 14:16:16, you wrote:
> TF> Hi !
> TF> I have read here and there a few messages talking about "PUT_Factor=
y"
> TF> scripts, which seem to enable us to create given objects types from=
> TF> informations transfered via HTTP or FTP "PUTs".
> TF> Where could I find informations about this method ? Does it have to=
be
> TF> implemented as a simple DTML Method, as a Python script or as an ex=
ternal
> TF> method ??
> TF> Any information would be really usefull to me...
> TF> Thanks,
> TF> Thierry
> =
> Did you get any responses to this enquiry?
> I have been wondering about the same issues, and have never gotten any
> good response..
> =
> :-)
Download HTMLDocument from zope.org to see how it works - have a look at
its __init__.py :
def PUT_factory( self, name, typ, body ):
from OFS.Image import Image, File
from OFS.DTMLDocument import DTMLDocument
if typ =3D=3D 'text/html':
ob =3D HTMLDocument.HTMLDocument('', __name__=3Dname)
elif typ in ('text/xml', 'text/plain'):
ob =3D DTMLDocument('', __name__=3Dname)
elif typ[:6] =3D=3D 'image/':
ob =3D Image(name, '', body, content_type=3Dtyp)
else:
ob =3D File(name, '', body, content_type=3Dtyp)
return ob
import webdav.NullResource
webdav.NullResource.NullResource._default_PUT_factory =3D PUT_factory
Enjoy,
Andreas