# $Id: SendStrategy.xotcl,v 1.2 2005/09/09 21:07:23 neumann Exp $ package provide xotcl::actiweb::sendStrategy 0.8 package require XOTcl # # some simple sending strategy classes -- to be used as mixins # for web objects # namespace eval ::xotcl::actiweb::sendStrategy { namespace import ::xotcl::* Class SendStrategy SendStrategy abstract instproc send {httpWrk string} # # send the response given from the place as plain text # Class Send=PlainString -superclass SendStrategy Send=PlainString instproc send {httpWrk string} { $httpWrk sendMsg $string text/plain } # # send the response given from the place with content # type of the obj, if it exists # Class Send=TypedString -superclass SendStrategy Send=TypedString instproc send {httpWrk string} { $httpWrk sendMsg $string [my set contentType] } # # send file specified in obj's instvar filename # Class Send=File -superclass SendStrategy Send=File instproc send {httpWrk {response ""}} { if {[my exists contentType]} { $httpWrk sendFile [my set filename] [my set contentType] } else { $httpWrk sendFile [my set filename] "" } } namespace export \ SendStrategy Send=PlainString Send=TypedString Send=File } namespace import ::xotcl::actiweb::sendStrategy::*