Re: cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread vegetax
Bengt Richter wrote: > On Mon, 02 May 2005 20:24:02 -0400, vegetax <[EMAIL PROTECTED]> wrote: > >>Irmen de Jong wrote: >> >>> vegetax wrote: >>>> How can i use cgi'like print statement in a multitreaded web framework? >>>> each thr

Re: cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread vegetax
vegetax wrote: > Jeff Epler wrote: > >> You could write something like >> class ThreadSpecificFile: >> def set_stdout(f): >> self.files[thread_id] = f >> def write(data): >> self.files[thread_id].write(da

Re: cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread vegetax
Jeff Epler wrote: > You could write something like > class ThreadSpecificFile: > def set_stdout(f): > self.files[thread_id] = f > def write(data): > self.files[thread_id].write(data) > sys.stdout = ThreadSpecificFile() > where you'll have to fill out

Re: cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread vegetax
Irmen de Jong wrote: > vegetax wrote: >> How can i use cgi'like print statement in a multitreaded web framework? >> each thread has its own Servlet instance with request/response objects, >> sys.stdout = self.response(which is a file like object) wont work because >&g

cgi "print statement" in multithreaded enviroment?

2005-05-02 Thread vegetax
How can i use cgi'like print statement in a multitreaded web framework? each thread has its own Servlet instance with request/response objects, sys.stdout = self.response(which is a file like object) wont work because all threads will set the same file object and it will be a concurrence mess. I

are properties thread safe in this context?

2005-05-01 Thread vegetax
Class Req: def __init__(s,headers): s.headers = headers referer =\ property(lambda s:s.headers['Connection'], lambda s,v:s.headers.__setitem__('referer',v)) each thread has its own instance of class Req, Req instances are not shared between threads -- http://

Re: poll: does name conventions in python matters?

2005-04-19 Thread vegetax
Peter Hansen wrote: > vegetax wrote: >> in python it is common to see naming >> inconsistencies ,methods,modules,packages,classes with names in every >> posible style: >> thisisalongmethod >> ThisIsALongMethod >> thisIsALongMethod >> this_is_a_long_me

poll: does name conventions in python matters?

2005-04-19 Thread vegetax
in python it is common to see naming inconsistencies ,methods,modules,packages,classes with names in every posible style: thisisalongmethod ThisIsALongMethod thisIsALongMethod this_is_a_long_method and even This_Is_A_Long_Method All over the place,even within one module! classic static languages d

Thoughts on some stdlib modules

2005-04-08 Thread vegetax
I was messing around in google looking for the available python form validation modules when i found this: http://www.jorendorff.com/articles/python/path/, and i realized that is very similar to my python fileutils module,which encapsulate,path operations,file operations,etc. And those thoughts co

Re: Python Google Server

2005-04-05 Thread vegetax
Fuzzyman wrote: > Of course - sorry. Thanks for the fix. Out of interest - why are you > using this... just for curiosity, or is it helpful ? because is fun to surf on the google cache, =) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Google Server

2005-04-05 Thread vegetax
Fuzzyman wrote: > Add the follwoing two lines to the start of the code : > > import urllib2 > txheaders = { 'User-agent' : 'Mozilla/4.0 (compatible; MSIE 6.0; > Windows NT 5.1; SV1; .NET CLR 1.1.4322)' } > > Then change the start of the send_head method to this : > > def send_head(self): >

Re: Python Google Server

2005-04-05 Thread vegetax
it works on opera and firefox on linux, but you cant search in the cached google! it would be more usefull if you could somehow search "only" in the cache instead of putting the straight link. maybe you could put a magic url to search in the cache, like search:"search terms" [EMAIL PROTECTED] wrot

Re: Python Google Server

2005-04-05 Thread vegetax
[EMAIL PROTECTED] wrote: lol ,cool hack!! make a slashdot article about it!! > I've hacked together a 'GoogleCacheServer'. It is based on > SimpleHTTPServer. Run the following script (hopefully google groups > won't mangle the indentation) and set your browser proxy settings to > 'localhost:8000'

variable arguments question

2005-03-14 Thread vegetax
if i have a dictionary: d = {'a':2,'b':3 } l = (1,2) how can i pass it to a generic function that takes variable keywords as arguments? same thing with variable arguments, i need to pass a list of arguments to the function def asd(**kw): print kw def efg(*arg): print arg asd(d) doesnt work asd

Re: dinamically altering a function

2005-03-12 Thread vegetax
Bengt Richter wrote: > On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <[EMAIL PROTECTED]> wrote: > >>Steven Bethard wrote: >> >>> vegetax wrote: >>>> I i need a decorator that adds a local variable in the function it >>>> decorates, probabl

Re: dinamically altering a function

2005-03-12 Thread vegetax
thanks , i guess the best option is a callable class which builds the functions with the common code. Once again,we REALLY need a patterns book for python. =/ -- http://mail.python.org/mailman/listinfo/python-list

Re: dinamically altering a function

2005-03-12 Thread vegetax
Steven Bethard wrote: > vegetax wrote: >> I i need a decorator that adds a local variable in the function it >> decorates, probably related with nested scopes, for example: >> >> def dec(func): >> def wrapper(obj = None): >> if not

dinamically altering a function

2005-03-12 Thread vegetax
I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj() return func() return wrapper() @dec() def fun(b): obj.desc = 'marked' obj.

Re: problem with recursion

2005-03-03 Thread vegetax
How can i use a counter inside the recursive function? This code gives me the error 'local variable 'c' referenced before assignment' #!/usr/bin/python from os import listdir from os.path import isdir,join,basename import HTMLgen dirpath = '/devel/python/html/test' COUNTER = 0 def rec(

Re: problem with recursion

2005-03-03 Thread vegetax
Alexander Zatvornitskiy wrote: > ?? vegetax! > > 03 ? 2005 ? 13:54, vegetax ? ? ?? ? All ?: > > v> I need this in order to print a directory tree with htmlgen library > v> which uses nested lists to represent trees. > As you see from output o

problem with recursion

2005-03-03 Thread vegetax
I am trying to make convert a directory "tree" in a list of list, but cant find the algoritm =( ,for example a directory tree like : +root  +doc    ele1    ele2    +doc3 ele3  +doc2   ele4  ele5 should convert into: root[  doc,  [ele1,ele2,doc3,[ele3]],  doc2,  [ele4],  

recursion problem

2005-03-03 Thread vegetax
I am trying to make convert a directory "tree" in a list of list, but cant find the algoritm =( ,for example a directory tree like : +root +doc ele1 ele2 +doc3 ele3 +doc2 ele4 ele5 should convert into: root[ doc, [ele1,ele2,doc3,[ele3]], doc2, [ele4],

Re: custom classes in sets

2005-02-14 Thread vegetax
Steven Bethard wrote: > vegetax wrote: >> How can i make my custom class an element of a set? >> >> class Cfile: >> def __init__(s,path): s.path = path >> >> def __eq__(s,other): >>print 'inside equals' >>return not os

RE: custom classes in sets

2005-02-13 Thread vegetax
Delaney, Timothy C (Timothy) wrote: > vegetax wrote: > >> def __hashcode__(s): return s.path.__hashcode__() > > Try __hash__ ... > > Tim Delaney sorry about the typo, it is indead __hash__() that i tried -- http://mail.python.org/mailman/listinfo/python-list

custom classes in sets

2005-02-13 Thread vegetax
How can i make my custom class an element of a set? class Cfile: def __init__(s,path): s.path = path def __eq__(s,other): print 'inside equals' return not os.popen('cmp %s %s' % (s.path,other.path)).read() def __hashcode__(s): return s.path.__hashcode__() the idea is that it accepts

wrapper classes question..

2005-02-09 Thread vegetax
Hi i made a wrapper class for handling file and dir operations and i wonder,  whats the performance penalty for making such wrapper classes? is it ok to make a lot of these wrappers? here it is: # import os class File(object): #access modes F_OK = os.F_OK, W_OK = os.

wrapper classes question

2005-02-09 Thread vegetax
Hi i made a wrapper class for handling file and dir operations and i wonder, whats the performance penalty for making such wrapper classes? here it is: ## import os class File(object): #access modes F_OK = os.F_OK, W_OK = os.W_OK, R_OK = os.R_OK,

java 5 could like python?

2005-01-12 Thread vegetax
I was a java developer one year ago ,before i moved to python i realy liked it at the beggining, but i got very disapointed lately since my previus two python proyects where relatively big,and python didnt feel well suited for the task. The reasons are mainly due to the standard library,the lan