[Zope-CMF] Virus check

Arjan Huizer a.huizer@kennisnet.org
Mon, 16 Jun 2003 14:22:16 +0200


Hi,

I am running Zope 2.6.1 together with CMF 1.3 on a linux box. I would =
like to run a virus check on all uploaded files in the CMF. I have =
installed FProt on my Linux server.=20

Next I created a python script in the skins directory (validate_file):

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
## Script (Python) "validate_file"
##parameters=3Dfile=3D''
##title=3DValidate a file

return 0
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D

and I customized the file_edit.py script in the skins/content directory:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
if context.validate_file(file=3Dfile):

    context.edit( precondition=3Dprecondition, file=3Dfile)
    qst=3D'portal_status_message=3DFile+changed.'
    if choice =3D=3D ' Change and View ':
        target_action =3D context.getTypeInfo().getActionById( 'view' )
    else:
        target_action =3D context.getTypeInfo().getActionById( 'edit' )

else:

    qst=3D'portal_status_message=3DFile+contains+virus.'
    target_action =3D context.getTypeInfo().getActionById( 'edit' )


context.REQUEST.RESPONSE.redirect( '%s/%s?%s' % ( context.absolute_url()
                                                , target_action
                                                , qst
                                                ) )
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D

When I upload a file I get the following error:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
Error Type: AttributeError=20
Error Value: validate_file=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

Note that when I customize the validate_file script, everything does =
work. Can someone tell me what I am missing here? Thanks in advance!!

Arjan Huijzer