Best architecture for proxy?
I am going to write a general-purpose modular proxy in Python. It will consist of a simple core and several modules for things like filtering and caching. I am not sure whether it is better to use multithreading, or to use an event-driven networking library like Twisted or Medusa/ Asyncore. Which would be the better architecture to use? -- http://mail.python.org/mailman/listinfo/python-list
Re: Best architecture for proxy?
On Jul 10, 8:19 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann wrote: > > Andrew Warkentin wrote: > > >> I am going to write a general-purpose modular proxy in Python. It > >> will consist of a simple core and several modules for things like > >> filtering and caching. I am not sure whether it is better to use > >> multithreading, or to use an event-driven networking library like > >> Twisted or Medusa/ Asyncore. Which would be the better > >> architecture to use? > > > I'd definitely use an event-driven approach with Twisted. > > > Generally, multithreading is less performant than multiplexing. High > > performance servers mostly use a combination of both, though. > > Converselt I'd recommend Medusa - not necessarily because it's "better", > but becuase I know it better. There's also a nice general-purpose proxy > program (though I'd be surprised if Twisted didn't also have one). > > Would an event-driven proxy be able to handle multiple connections with large numbers of possibly CPU-bound filters? I use The Proxomitron (and would like to write my own proxy that can use the same filter sets, but follows the Unix philosophy) and some of the filters appear to be CPU-bound, because they cause The Proxomitron to hog the CPU (although that might just be a Proxomitron design flaw or something). Wouldn't CPU-bound filters only allow one connection to be filtered at a time? On the Medusa site, it said that an event-driven architecture only works for I/O-bound programs. -- http://mail.python.org/mailman/listinfo/python-list
Python-based regular expression parser that allows patterns to call functions?
I am writing a filtering HTTP proxy (the site is http://xuproxy.sourceforge.net/). I want it to be compatible with Proxomitron (http://proxomitron.info/) filters. I need a regular expression parser that allows patterns to call functions (or more likely, class methods), to implement "matching commands" (look at the Proxmitron documentation to see what I mean). Does anyone know if such a library exists for Python, or do I have to write my own parser? -- http://mail.python.org/mailman/listinfo/python-list
Re: ActiveX in Webpage?
Michael Wieher wrote: > Hello, > > I'm trying to design a python-based web-app from scratch, based on a > standalone MFC application. > Obviously I'll be wrapping a lot of C++ functionality in custom > extensions, but is anyone aware of any documentation/techniques that > could help me "drop" an ActiveX control into a webpage, and just use it? > That, or, of course, a solid bit of writing detailing the > idiosyncrasies of MFC-wrapped Py-Extensions would be useful as well. > > -Mike I would recommend against embedding ActiveX controls, especially if this web application is public (if it is internal, it's not as much of a problem, but you still might have problems later if you ever want to migrate off Windows). ActiveX controls are not only Windows-specific, but (mostly) IE-specific as well. Since you are developing it from scratch, I would say that you should do it right and use AJAX, or possibly Flash or Java applets, all of which are reasonably portable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to check if string is an integer?
[EMAIL PROTECTED] wrote: >which is the best way to check if a string is an number or a char? >could the 2nd example be very expensive timewise if i have to check a >lot of strings? > >this > >value = raw_input() > >try: >value = int(value) >except ValueError: >print "value is not an integer" > > >or: > > >c=raw_input("yo: ") >if c in '0123456789': >print "integer" >else: >print "char" > > > >or some other way? > > I always do it the first way. It is simpler, and should be faster. Also, the second way will only work on single-digit numbers (you would have to iterate over the entire string with a for loop to use it on numbers with more than one digit). -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding classes to modules at runtime from outside that module
[EMAIL PROTECTED] wrote: > In Python, is it possible to add classes to a module at run-time? > > Say I have a module foo and a module bar. Foo has class A and B, and >bar has class C. I want to add class C to foo so I can access it as >foo.C, but i want to do it without modifying foo's source. > > Is this at all possible? > > Yes. You would do something like import foo import bar foo.C = bar.C -- http://mail.python.org/mailman/listinfo/python-list
Suitable libraries for implementing a "push"-type matching engine?
I am trying to write a matching engine for a matching language for a filtering proxy compatible with that of The Proxomitron. The matching language is basically an extended superset of shell-style globs, with functionality comparable to regexps (see http://www.proxomitron.info/45/help/Matching%20Rules.html). Can anyone recommend any Python libraries that would be suitable for my purposes? I think that I can implement a parser for the patterns themselves with pyparsing, but I'm not sure if anything suitable for finding matches in an input stream of text exists. I don't want to reinvent the wheel if I don't have to. A matching engine for a filtering proxy has to be able to handle partial input and "hold" data until enough is received to determine whether there is a match (or else the entire document would have to be held until the end is reached, filtered, and then sent all at once to the remote client, and that would make it appear much less responsive and possibly break some applications). I also need to be able to associate specific patterns (matching commands and certain backslash-escapes) with functions that are called to determine if they match. -- http://mail.python.org/mailman/listinfo/python-list