[Twisted-Python] cross service events and why on earth ?

skoegl at online.de skoegl at online.de
Wed Jul 16 03:03:18 MDT 2008


hi,

I have to deal with flash players (I'm deeply ashamed for what I'm doing ;-), and their somewhat cumberstone constraints. 

The main part of the communication is handled via an tcp socket using the amf protocol. But I have to handle "file uploads" via http POST multipart from client to server and sending it back to the flash player since flash only allows domain specific content - no content from the users' file system. 

So my first attempt to solve this big mess was to create a tac like that:

############################################
tac file
############################################

import sys, os

sys.path.append(os.getcwd())

from twisted.application import internet, service

# my custom backend factory subclassed from ServerFactory
from socketManager import SocketManager 

from policySocketFactory import PolicySocketFactory
from twisted.web2 import server, channel, static
from twisted.application import service, strports
from fileupload import Toplevel

application = service.Application('backend')

# backend service - all client/server communication should go via that sockets
backendService = internet.TCPServer(8600, SocketManager())
backendService.setServiceParent(application)

# policy service
socketPolicyService = internet.TCPServer(8601, PolicySocketFactory('socket-policy.xml'))
socketPolicyService.setServiceParent(application)

# http service
site = server.Site(Toplevel())
fileUploadService = strports.service('tcp:8080', channel.HTTPFactory(site))
fileUploadService.setServiceParent(application)

############################################

Authentication /Authorization is implemented in the backend service, so I'm searching for a solution to fire some sort of event in the fileUploadService to be handled in the backendService, and to restrict the file upload to already logged in users. I thought about using "inotify" for watching the upload directory, but I would prefer a twisted /pythonic solution. Perhaps someone could give me some advice about what would be a sane way to solve this 2 problems. 

Thank you in advance,

Stefan Kögl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20080716/99bc7edf/attachment.html>


More information about the Twisted-Python mailing list