jtoolkit-cvs Mailing List for jToolkit (Page 6)
Brought to you by:
davidfraser,
friedelwolff
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(15) |
Oct
(12) |
Nov
|
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
(100) |
Mar
(27) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dav...@us...> - 2004-02-09 12:23:20
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19649 Modified Files: database.py Log Message: added code to create separate caches for separate tables (not thoroughly tested yet!) Index: database.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/database.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** database.py 9 Feb 2004 12:17:31 -0000 1.5 --- database.py 9 Feb 2004 12:19:59 -0000 1.6 *************** *** 83,87 **** class dbwrapper: ! def __init__(self, instance, errorhandler=None): """initialises the dbwrapper class...""" if errorhandler is None: --- 83,87 ---- class dbwrapper: ! def __init__(self, instance, errorhandler=None, cachetables=None): """initialises the dbwrapper class...""" if errorhandler is None: *************** *** 103,113 **** self.lower = lower self.dbtypenames = dbtypenames[self.DBTYPE] ! self.singlerowcache = timecache.timecache(120) ! self.allrowscache = timecache.timecache(170) ! def clearcache(self): ! # TODO: purge only part of cache based on table name... ! self.singlerowcache.clear() ! self.allrowscache.clear() def importdriver(self): --- 103,139 ---- self.lower = lower self.dbtypenames = dbtypenames[self.DBTYPE] ! # set up caches ! self.cachetables = [] ! self.singlerowcaches = cidict.cidict({'': timecache.timecache(120)}) ! self.allrowscaches = cidict.cidict({'': timecache.timecache(170)}) ! if cachetables is not None: ! for cachetable, expirytime in self.cachetables: ! self.cachetables.append(cachetable) ! self.singlerowcaches[cachetable] = timecache.timecache(expirytime) ! self.allrowscaches[cachetable] = timecache.timecache(expirytime) ! def clearcache(self, cachetables): ! """clears all the caches for the given sql command""" ! if len(cachetables) == 0: ! self.singlerowcaches[''].clear() ! self.allrowscaches[''].clear() ! else: ! for cachetable in cachetables: ! # TODO: handle ripple-through effects... ! if not cachetable in self.cachetables: ! self.singlerowcaches[''].clear() ! self.allrowscaches[''].clear() ! else: ! self.singlerowcaches[cachetable].clear() ! self.allrowscaches[cachetable].clear() ! ! def getcachetables(self, sql): ! """returns the list of cacheable tables that occur in the sql statement""" ! cachetables = [] ! sql = sql.lower() ! for cachetable in self.cachetables: ! if sql.find(cachetable.lower()) != -1: ! cachetables.append(cachetable) ! return cachetables def importdriver(self): *************** *** 151,155 **** cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache() self.db.commit() return cursor --- 177,181 ---- cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache(self.getcachetables(sql)) self.db.commit() return cursor *************** *** 164,167 **** --- 190,194 ---- try: cursor = self.db.cursor() + self.errorhandler.logtrace("uncacheable sql query: " + str(sql)) cursor.execute(sql) self.db.commit() *************** *** 251,255 **** cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache() self.db.commit() except self.dberror: --- 278,282 ---- cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache([tablename]) self.db.commit() except self.dberror: *************** *** 296,300 **** cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache() self.db.commit() except self.dberror: --- 323,327 ---- cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache([tablename]) self.db.commit() except self.dberror: *************** *** 311,315 **** cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache() self.db.commit() except self.dberror: --- 338,342 ---- cursor = self.db.cursor() cursor.execute(sql) ! self.clearcache([tablename]) self.db.commit() except self.dberror: *************** *** 343,349 **** print def singlerow(self, sql, withdescription=0): """runs sql and retrieves a single row""" ! cachedrow, description = self.singlerowcache.get(sql, (None, None)) if cachedrow is not None: if withdescription: --- 370,400 ---- print + def getsinglerowcache(self, sql): + """returns cached single row result for the sql statement""" + cachetables = self.getcachetables(sql) + if len(cachetables) == 0: + cachedrow, description = self.singlerowcaches[''].get(sql, (None, None)) + elif len(cachetables) == 1: + cachedrow, description = self.singlerowcaches.get(cachetables[0], self.singlerowcaches['']).get(sql, (None, None)) + else: + # TODO: check that it's the same for all of them + cachedrow, description = self.singlerowcaches.get(cachetables[0], self.singlerowcaches['']).get(sql, (None, None)) + return cachedrow, description + + def setsinglerowcache(self, sql, cachedrow, description): + """caches single row result for the sql statement""" + cachetables = self.getcachetables(sql) + if len(cachetables) == 0: + self.singlerowcaches[''][sql] = (cachedrow, description) + else: + for cachetable in cachetables: + if cachetable in self.cachetables: + self.singlerowcaches[cachetables][sql] = (cachedrow, description) + else: + self.singlerowcaches[''][sql] = (cachedrow, description) + def singlerow(self, sql, withdescription=0): """runs sql and retrieves a single row""" ! cachedrow, description = self.getsinglerowcache(sql) if cachedrow is not None: if withdescription: *************** *** 355,359 **** # return None for each field row = [None] * len(cursor.description) ! self.singlerowcache[sql] = row, cursor.description if withdescription: return row, cursor.description --- 406,410 ---- # return None for each field row = [None] * len(cursor.description) ! self.setsinglerowcache(sql, row, cursor.description) if withdescription: return row, cursor.description *************** *** 365,371 **** return row[0] def allrows(self, sql, withdescription=0): """runs sql and retrieves all rows""" ! cachedrows, description = self.allrowscache.get(sql, (None, None)) if cachedrows is not None: if withdescription: --- 416,446 ---- return row[0] + def getallrowscache(self, sql): + """returns cached all rows result for the sql statement""" + cachetables = self.getcachetables(sql) + if len(cachetables) == 0: + cachedrows, description = self.allrowscaches[''].get(sql, (None, None)) + elif len(cachetables) == 1: + cachedrows, description = self.allrowscaches.get(cachetables[0], self.allrowscaches['']).get(sql, (None, None)) + else: + # TODO: check that it's the same for all of them + cachedrows, description = self.allrowscaches.get(cachetables[0], self.allrowscaches['']).get(sql, (None, None)) + return cachedrows, description + + def setallrowscache(self, sql, cachedrows, description): + """caches all rows result for the sql statement""" + cachetables = self.getcachetables(sql) + if len(cachetables) == 0: + self.allrowscaches[''][sql] = (cachedrows, description) + else: + for cachetable in cachetables: + if cachetable in self.cachetables: + self.allrowscaches[cachetables][sql] = (cachedrows, description) + else: + self.allrowscaches[''][sql] = (cachedrows, description) + def allrows(self, sql, withdescription=0): """runs sql and retrieves all rows""" ! cachedrows, description = self.getallrowscache(sql) if cachedrows is not None: if withdescription: *************** *** 374,378 **** cursor = self.query(sql) rows = cursor.fetchall() ! self.allrowscache[sql] = rows, cursor.description if withdescription: return rows, cursor.description --- 449,453 ---- cursor = self.query(sql) rows = cursor.fetchall() ! self.setallrowscache(sql, rows, cursor.description) if withdescription: return rows, cursor.description |
From: <dav...@us...> - 2004-02-09 12:20:44
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19154 Modified Files: database.py Log Message: adjusted times on caches Index: database.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/database.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** database.py 14 Oct 2003 09:34:06 -0000 1.4 --- database.py 9 Feb 2004 12:17:31 -0000 1.5 *************** *** 103,108 **** self.lower = lower self.dbtypenames = dbtypenames[self.DBTYPE] ! self.singlerowcache = timecache.timecache(5) ! self.allrowscache = timecache.timecache(10) def clearcache(self): --- 103,108 ---- self.lower = lower self.dbtypenames = dbtypenames[self.DBTYPE] ! self.singlerowcache = timecache.timecache(120) ! self.allrowscache = timecache.timecache(170) def clearcache(self): |
From: <dav...@us...> - 2003-12-02 08:26:13
|
Update of /cvsroot/jtoolkit/jToolkit In directory sc8-pr-cvs1:/tmp/cvs-serv14305 Modified Files: sparse.py Log Message: added support for escaping in strings... Index: sparse.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/sparse.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sparse.py 25 Aug 2003 12:16:45 -0000 1.2 --- sparse.py 2 Dec 2003 08:26:08 -0000 1.3 *************** *** 36,45 **** laststart = 0 instring = 0 ! stringchar = '' ! gotclose = 0 for pos in range(len(input)): char = input[pos] if instring: ! if char == stringchar: gotclose = not gotclose elif gotclose: --- 36,47 ---- laststart = 0 instring = 0 ! stringchar, escapechar = '', '\\' ! gotclose, gotescape = 0, 0 for pos in range(len(input)): char = input[pos] if instring: ! if (gotescape or char == escapechar) and not gotclose: ! gotescape = not gotescape ! elif char == stringchar: gotclose = not gotclose elif gotclose: |
From: <dav...@us...> - 2003-12-02 08:24:58
|
Update of /cvsroot/jtoolkit/jToolkit In directory sc8-pr-cvs1:/tmp/cvs-serv13956 Modified Files: localize.py Log Message: added default charset Index: localize.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/localize.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** localize.py 29 Sep 2003 07:58:02 -0000 1.4 --- localize.py 2 Dec 2003 08:24:53 -0000 1.5 *************** *** 50,53 **** --- 50,55 ---- for translation in self.translations: tmsg = translation._catalog.get(message, None) + # TODO: we shouldn't set _charset like this. make sure it is set properly + if translation._charset is None: translation._charset = 'iso8859' if tmsg is not None: return unicode(tmsg, translation._charset) |
From: <dav...@us...> - 2003-12-02 08:21:48
|
Update of /cvsroot/jtoolkit/jToolkit In directory sc8-pr-cvs1:/tmp/cvs-serv13467 Modified Files: cidict.py Log Message: added more intelligense to handle str/unicode comparisons added an ordereddict class Index: cidict.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/cidict.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cidict.py 25 Sep 2003 17:36:55 -0000 1.3 --- cidict.py 2 Dec 2003 08:21:43 -0000 1.4 *************** *** 21,24 **** --- 21,26 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + from __future__ import generators + def filterdict(origdict, keyset): """returns the subset of origdict containing only the keys in keyset and their corresponding values """ *************** *** 41,44 **** --- 43,54 ---- if (type(lvalue) != type(rvalue)) and not (type(lvalue) in (str, unicode) and type(rvalue) in (str, unicode)): diffdict[key] = lvalue + elif type(lvalue) != type(rvalue): + # handle str/unicode mismatch + if type(lvalue) == str: lvaluecmp = lvalue.decode('iso8859') + else: lvaluecmp = lvalue + if type(rvalue) == str: rvaluecmp = rvalue.decode('iso8859') + else: rvaluecmp = rvalue + if lvaluecmp != rvaluecmp: + diffdict[key] = lvalue elif lvalue != rvalue: diffdict[key] = lvalue *************** *** 119,121 **** --- 129,211 ---- else: return default + + class ordereddict(dict): + """a dictionary which remembers its keys in the order in which they were given""" + def __init__(self, *args): + if len(args) == 0: + super(ordereddict, self).__init__() + self.order = [] + elif len(args) > 1: + raise TypeError("ordereddict() takes at most 1 argument (%d given)" % len(args)) + else: + initarg = args[0] + apply(super(ordereddict, self).__init__, args) + if hasattr(initarg, "keys"): + self.order = initarg.keys() + else: + # danger: could have duplicate keys... + self.order = [] + checkduplicates = {} + for key, value in initarg: + if not key in checkduplicates: + self.order.append(key) + checkduplicates[key] = None + + def __setitem__(self, key, value): + alreadypresent = key in self + result = dict.__setitem__(self, key, value) + if not alreadypresent: self.order.append(key) + return result + + def update(self, updatedict): + """D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]""" + for key, value in updatedict.iteritems(): + self[key] = value + + def __delitem__(self, key): + alreadypresent = key in self + result = dict.__delitem__(self, key) + if not alreadypresent: del self.order[self.order.find(key)] + return result + + def copy(self): + """D.copy() -> a shallow copy of D""" + thecopy = ordereddict(super(ordereddict, self).copy()) + thecopy.order = self.order[:] + return thecopy + + def items(self): + """D.items() -> list of D's (key, value) pairs, as 2-tuples""" + return [(key, self[key]) for key in self.order] + + def iteritems(self): + """D.iteritems() -> an iterator over the (key, value) items of D""" + for key in self.order: + yield (key, self[key]) + + def iterkeys(self): + """D.iterkeys() -> an iterator over the keys of D""" + for key in self.order: + yield key + + __iter__ = iterkeys + + def itervalues(self): + """D.itervalues() -> an iterator over the values of D""" + for key in self.order: + yield self[key] + + def keys(self): + """D.keys() -> list of D's keys""" + return self.order[:] + + def popitem(self): + """D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty""" + if len(self.order) == 0: + raise KeyError("popitem(): ordered dictionary is empty") + k = self.order.pop() + v = self[k] + del self[k] + return (k,v) + |
From: <dav...@us...> - 2003-12-02 08:17:04
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv12441 Added Files: simplewebserver.py Log Message: added simple web server for serving files without apache --- NEW FILE: simplewebserver.py --- #!/usr/bin/python2.2 """a simple web server so you don't have to run your app from inside Apache etc. mostly useful for testing / small setups""" # Copyright 2002, 2003 St James Software # # This file is part of jToolkit. # # jToolkit is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # jToolkit is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with jToolkit; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import BaseHTTPServer import urllib import posixpath import cgi import sys import os from jToolkit.web import getserver from jToolkit.web import httpcodes from jToolkit.widgets import widgets runforever = 1 server = getserver("jLogbook.python.config", "Demo") def run(server_class=BaseHTTPServer.HTTPServer, handler_class=BaseHTTPServer.BaseHTTPRequestHandler, port=9980): server_address = ('', port) httpd = server_class(server_address, handler_class) if runforever: # this means the server has to be interrupted manually... httpd.serve_forever() else: # otherwise, only handle one request, to aid debugging httpd.handle_request() class jToolkitHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): # methods based on *.webserver # TODO: inherit from something appropriate... def reset_response(self): self.sent_response = 0 protocol_version = "HTTP/1.1" def send_response_normal(self): """set up for a normal process""" # TODO: change this to a constant self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() def send_response_unauthorized(self, realm): # hold back the message till later... # TODO: change this to a constant self.send_response(401, 0) self.send_header("WWW-Authenticate", "Basic realm=%s" % repr(realm)) # now we can send the message... self.send_response_message(401) def writeline(self, line): """writes a line back to the client...""" # if no response yet, tell them we're OK if not self.sent_response: self.send_response_normal() self.wfile.write(line+'\n') # stuff based on BaseHTTPServer server_version = 'jToolkitHTTP/0.1' def log_message(self, format, *args): """Log an arbitrary message. This is used by all other logging functions. Override it if you have specific logging wishes. The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it's just like printf!). The client host and current date/time are prefixed to every message. """ if not hasattr(self,'authuser'): self.authuser = '-' sys.stderr.write("%s - %s [%s] %s\n" % (self.address_string(), self.authuser, self.log_date_time_string(), format%args)) def do_GET(self): """Serve a GET request""" self.authuser = '-' querypos = self.path.find('?') if '?' != -1: path = self.path[:querypos] querystring = self.path[querypos+1:] argdict = cgi.parse_qs(querystring, 1, 0) else: path = self.path argdict = {} path = posixpath.normpath(urllib.unquote(path)) pathwords = filter(None, path.split('/')) # split into bits, strip out empty strings if len(pathwords) > 0 and pathwords[-1] == '.': pathwords = pathwords[:-1] sys.stderr.write("%r %r %r\n" % (path, pathwords, argdict)) # forget if we've served a response previously... self.reset_response() thepage = server.handle(self, pathwords, argdict) # session = server.getsession(self, argdict, None) # thepage = server.getpage(pathwords, session, argdict) self.sendpage(thepage) def sendpage(self, thepage): """sends the page back to the user""" # TODO: refactor this into jToolkit.web.server? if isinstance(thepage, widgets.Widget): # get the content type... if hasattr(thepage,'content_type'): content_type = thepage.content_type else: content_type = "text/html" response = thepage.gethtml() # return the html response (whether customized or standard) self.send_response(200) self.send_header("Content-type", content_type) self.end_headers() if type(response) == unicode: # TODO: get encoding from http request... self.wfile.write(response.encode('iso8859')) else: self.wfile.write(response) elif thepage is None: return self.send_response(404) # safeapache.apache.DECLINED else: # a non-widget means a return code... actually an integer, not a page return self.send_response(thepage) # safeapache.apache.DECLINED def do_POST(self): """Serve a POST request""" self.authuser = '-' contenttype = self.headers.gettype() if contenttype <> 'application/x-www-form-urlencoded': # check this self.send_response(501) self.end_headers() return contentlength = int(self.headers.getheader('Content-Length')) querystring = self.rfile.read(contentlength) argdict = cgi.parse_qs(querystring, 1, 0) path = posixpath.normpath(urllib.unquote(self.path)) pathwords = filter(None, path.split('/')) # split into bits, strip out empty strings # forget if we've served a response previously... self.reset_response() thepage = server.handle(self, pathwords, argdict) self.sendpage(thepage) def logpid(): pidfile = os.getenv('jtoolkit_pid_file') if pidfile is None: pidfile = "jtoolkit.pid" pid = os.getpid() f = open(pidfile,'w') f.write('%d' % pid) f.close() if __name__ == '__main__': # run the web server if "-B" in sys.argv: del sys.argv[sys.argv.index("-B")] # fork into background import os if os.fork(): # exit the parent sys.exit() # log the pid... logpid() if "-o" in sys.argv: oindex = sys.argv.index("-o") ofile = sys.argv[oindex+1] del sys.argv[oindex] del sys.argv[oindex] # print "writing to %r" % ofile sys.stdout = open(ofile,'a') sys.stderr = sys.stdout print "remaining args: %r" % sys.argv if len(sys.argv) > 1: port = int(sys.argv[1]) run(handler_class=jToolkitHTTPRequestHandler,port=port) else: run(handler_class=jToolkitHTTPRequestHandler) |
From: <dav...@us...> - 2003-10-14 15:50:19
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv31561 Modified Files: safeapache.py Log Message: took out unneccessary sys import Index: safeapache.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/safeapache.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** safeapache.py 25 Sep 2003 17:36:55 -0000 1.3 --- safeapache.py 14 Oct 2003 15:50:06 -0000 1.4 *************** *** 24,29 **** # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - import sys - class FakeConnection: user = 'testuser' --- 24,27 ---- |
From: <dav...@us...> - 2003-10-14 15:48:14
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv31024 Modified Files: session.py Log Message: moved invalidatechild around to make sure it's always there. set username in __init__ so everyone knows it's there (particularly pychecker :-)) Index: session.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/session.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** session.py 25 Sep 2003 17:36:55 -0000 1.3 --- session.py 14 Oct 2003 15:48:09 -0000 1.4 *************** *** 155,158 **** --- 155,159 ---- self.status = "" self.setlanguage(None) + self.username = None # allow the server to add any attributes it requires server.initsession(self) *************** *** 202,205 **** --- 203,212 ---- self.invalidatechild(childname) + def invalidatechild(self, childname): + """logs out of a child session""" + childsession = self.childsessions.get(childname, 0) + if childsession: + childsession.markinvalid() + def updatelastused(self): """updates that the session has been used""" *************** *** 381,390 **** othersession.username = otherusername othersession.status = "" - - def invalidatechild(self, childname): - """logs out of a child session""" - childsession = self.childsessions.get(childname, 0) - if childsession: - childsession.markinvalid() def confirmlogin(self, req, username, password, timestamp): --- 388,391 ---- |
From: <dav...@us...> - 2003-10-14 15:47:30
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv30884 Modified Files: __init__.py server.py Added Files: httpcodes.py Log Message: added new module httpcodes as more generic way to return http status modified server.py to use httpcodes wherever possible, __init__.py to convert them for modpython/apache also moved reading the arguments from the request out of the server (to make it more generic) so now each handle object takes a argdict parameter this makes things more flexible as each server can processargs without worrying about others... added error trapping for import code in __init__.py rearranged logging code to make it cleaner --- NEW FILE: httpcodes.py --- #!/usr/bin/python """constants for HTTP status codes""" # Copyright 2002, 2003 St James Software # # This file is part of jToolkit. # # jToolkit is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # jToolkit is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with jToolkit; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA CONTINUE = 100 SWITCHING_PROTOCOLS = 101 PROCESSING = 102 OK = 200 CREATED = 201 ACCEPTED = 202 NON_AUTHORITATIVE = 203 NO_CONTENT = 204 RESET_CONTENT = 205 PARTIAL_CONTENT = 206 MULTI_STATUS = 207 MULTIPLE_CHOICES = 300 MOVED_PERMANENTLY = 301 MOVED_TEMPORARILY = 302 SEE_OTHER = 303 NOT_MODIFIED = 304 USE_PROXY = 305 TEMPORARY_REDIRECT = 307 BAD_REQUEST = 400 UNAUTHORIZED = 401 PAYMENT_REQUIRED = 402 FORBIDDEN = 403 NOT_FOUND = 404 METHOD_NOT_ALLOWED = 405 NOT_ACCEPTABLE = 406 PROXY_AUTHENTICATION_REQUIRED= 407 REQUEST_TIME_OUT = 408 CONFLICT = 409 GONE = 410 LENGTH_REQUIRED = 411 PRECONDITION_FAILED = 412 REQUEST_ENTITY_TOO_LARGE = 413 REQUEST_URI_TOO_LARGE = 414 UNSUPPORTED_MEDIA_TYPE = 415 RANGE_NOT_SATISFIABLE = 416 EXPECTATION_FAILED = 417 UNPROCESSABLE_ENTITY = 422 LOCKED = 423 FAILED_DEPENDENCY = 424 INTERNAL_SERVER_ERROR = 500 NOT_IMPLEMENTED = 501 BAD_GATEWAY = 502 SERVICE_UNAVAILABLE = 503 GATEWAY_TIME_OUT = 504 VERSION_NOT_SUPPORTED = 505 VARIANT_ALSO_VARIES = 506 INSUFFICIENT_STORAGE = 507 NOT_EXTENDED = 510 Index: __init__.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** __init__.py 14 Oct 2003 08:25:55 -0000 1.5 --- __init__.py 14 Oct 2003 15:47:25 -0000 1.6 *************** *** 20,23 **** --- 20,25 ---- import sys + from jToolkit.web import safeapache + from jToolkit.web import httpcodes # list of modules in this package *************** *** 30,33 **** --- 32,49 ---- logtimes = 0 + def logtimetofile(message): + osid = os.getpid() + threadid = thread.get_ident() + t = time.time() + ms = int((t - int(t))*1000.0) + timestr = time.strftime('%Y-%m-%d %H:%M:%S') + '.%03d' % ms + f = open(logfilename, 'a') + f.write('%s: pid %r tid %r: %s\n' % (timestr, osid, threadid, message)) + f.close() + + def logtimetonowhere(message): + """don't log anything as we aren't in logtimes mode""" + pass + if logtimes: import os, time *************** *** 42,59 **** thread.get_ident = thread_get_ident logfilename = '/tmp/threads.log' ! ! def logtime(message): ! osid = os.getpid() ! threadid = thread.get_ident() ! t = time.time() ! ms = int((t - int(t))*1000.0) ! timestr = time.strftime('%Y-%m-%d %H:%M:%S') + '.%03d' % ms ! f = open(logfilename, 'a') ! f.write('%s: pid %r tid %r: %s\n' % (timestr, osid, threadid, message)) ! f.close() else: ! def logtime(message): ! """don't log anything as we aren't in logtimes mode""" ! pass def getserver(modulename, instancename): --- 58,64 ---- thread.get_ident = thread_get_ident logfilename = '/tmp/threads.log' ! logtime = logtimetofile else: ! logtime = logtimetonowhere def getserver(modulename, instancename): *************** *** 93,101 **** server = getserver(modulename, instancename) pathwords = filter(None, req.uri.split('/')) # split into bits, strip out empty strings logtime('calling server.handle: ' + req.uri) ! thepage = server.handle(req, pathwords) logtime('calling server.sendpage: ' + req.uri) result = server.sendpage(req, thepage) logtime('done: ' + req.uri) return result --- 98,109 ---- server = getserver(modulename, instancename) pathwords = filter(None, req.uri.split('/')) # split into bits, strip out empty strings + argdict = safeapache.util.FieldStorage(req) logtime('calling server.handle: ' + req.uri) ! thepage = server.handle(req, pathwords, argdict) logtime('calling server.sendpage: ' + req.uri) result = server.sendpage(req, thepage) logtime('done: ' + req.uri) + if result is None: return safeapache.apache.DECLINED + if result == httpcodes.OK: return safeapache.apache.OK return result Index: server.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/server.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** server.py 14 Oct 2003 09:36:49 -0000 1.6 --- server.py 14 Oct 2003 15:47:25 -0000 1.7 *************** *** 25,29 **** from jToolkit.data import database ! from jToolkit.web import safeapache from jToolkit.web import session from jToolkit import errors --- 25,29 ---- from jToolkit.data import database ! from jToolkit.web import httpcodes from jToolkit.web import session from jToolkit import errors *************** *** 39,43 **** widgets.Page.__init__(self, title, contents=[]) self.confirmlogin = confirmlogin ! self.processargs(extraargs) self.specialmessage = specialmessage self.languagenames = languagenames --- 39,43 ---- widgets.Page.__init__(self, title, contents=[]) self.confirmlogin = confirmlogin ! self.handleextraargs(extraargs) self.specialmessage = specialmessage self.languagenames = languagenames *************** *** 48,52 **** return session.localize("Login for %s") % (session.instance.__name__) ! def processargs(self, extraargs): """process the arguments given, and add neccessary args to a hidden widgets list""" self.action = '' --- 48,52 ---- return session.localize("Login for %s") % (session.instance.__name__) ! def handleextraargs(self, extraargs): """process the arguments given, and add neccessary args to a hidden widgets list""" self.action = '' *************** *** 139,150 **** req.send_http_header() req.write(response) ! return safeapache.apache.OK else: req.headers_out.add('Location', self.location) if self.ispermanent: ! req.status = safeapache.apache.HTTP_MOVED_PERMANENTLY else: ! req.status = safeapache.apache.HTTP_MOVED_TEMPORARILY ! return safeapache.apache.OK class AppServer(object): --- 139,149 ---- req.send_http_header() req.write(response) ! return httpcodes.OK else: req.headers_out.add('Location', self.location) if self.ispermanent: ! return httpcodes.MOVED_PERMANENTLY else: ! return httpcodes.MOVED_TEMPORARILY class AppServer(object): *************** *** 179,185 **** self.defaultlanguage = localize.getdefaultlanguage(self.languagelist) ! def handle(self, req, pathwords): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, req) session = self.getsession(req, argdict) session.pagecount += 1 --- 178,184 ---- self.defaultlanguage = localize.getdefaultlanguage(self.languagelist) ! def handle(self, req, pathwords, argdict): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, argdict) session = self.getsession(req, argdict) session.pagecount += 1 *************** *** 212,227 **** else: req.write(response) ! return safeapache.apache.OK elif isinstance(thepage, Redirect): return thepage.sendredirect(req) elif thepage is None: ! return safeapache.apache.DECLINED else: # a non-widget means a return code... actually an integer, not a page return thepage ! def processargs(self, instance, req): """return a dictionary of the set of arguments in a request...""" - argdict = safeapache.util.FieldStorage(req) newdict = {} for key in argdict.keys(): --- 211,226 ---- else: req.write(response) ! return httpcodes.OK elif isinstance(thepage, Redirect): return thepage.sendredirect(req) elif thepage is None: ! # return None to indicate we didn't produce a page (usually means Apache/webserver will handle it) ! return None else: # a non-widget means a return code... actually an integer, not a page return thepage ! def processargs(self, instance, argdict): """return a dictionary of the set of arguments in a request...""" newdict = {} for key in argdict.keys(): *************** *** 279,285 **** self.loginpageclass = loginpageclass ! def handle(self, req, pathwords): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, req) session = self.getsession(req, argdict) if session.isopen: --- 278,284 ---- self.loginpageclass = loginpageclass ! def handle(self, req, pathwords, argdict): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, argdict) session = self.getsession(req, argdict) if session.isopen: *************** *** 339,363 **** if len(pathwords) > 0: top = pathwords[0] - tail = pathwords[1:] if top not in ('', 'index.htm', 'index.html'): return 1 return 0 ! def handledefer(self, req, pathwords): """handles deferring the request to another server""" server = self.getserver(pathwords) if server is None: return None ! return server.handle(req, pathwords[1:]) ! def handle(self, req, pathwords): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): if pathwords[0] in self.instances: ! return self.handledefer(req, pathwords) else: return None else: ! argdict = self.processargs(self.instance, req) return self.getpage(pathwords, None, argdict) --- 338,361 ---- if len(pathwords) > 0: top = pathwords[0] if top not in ('', 'index.htm', 'index.html'): return 1 return 0 ! def handledefer(self, req, pathwords, argdict): """handles deferring the request to another server""" server = self.getserver(pathwords) if server is None: return None ! return server.handle(req, pathwords[1:], argdict) ! def handle(self, req, pathwords, argdict): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): if pathwords[0] in self.instances: ! return self.handledefer(req, pathwords, argdict) else: return None else: ! argdict = self.processargs(self.instance, argdict) return self.getpage(pathwords, None, argdict) *************** *** 380,386 **** class SharedLoginAppServer(LoginAppServer): """allows instance to be passed a shared session...""" ! def handle(self, req, pathwords, sharedsession=None): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, req) exitapp = argdict.get('exitapp', 0) session = self.getsession(req, argdict, sharedsession) --- 378,384 ---- class SharedLoginAppServer(LoginAppServer): """allows instance to be passed a shared session...""" ! def handle(self, req, pathwords, argdict, sharedsession=None): """handles the request and returns a page object in response""" ! argdict = self.processargs(self.instance, argdict) exitapp = argdict.get('exitapp', 0) session = self.getsession(req, argdict, sharedsession) *************** *** 411,420 **** """constructs the multi-app server""" if sessioncache is None: ! sessioncache = session.SessionCache(sessionclass=LoginSession,sessioncookiename=instance.__name__+'session') super(SharedLoginMultiAppServer, self).__init__(instance, sessioncache, errorhandler, loginpageclass) self.instances = self.instance.instances self.servers = {} ! def handledefer(self, req, pathwords, session=None): """handles deferring the request to another server""" server = self.getserver(pathwords) --- 409,418 ---- """constructs the multi-app server""" if sessioncache is None: ! sessioncache = session.SessionCache(sessionclass=session.LoginSession,sessioncookiename=instance.__name__+'session') super(SharedLoginMultiAppServer, self).__init__(instance, sessioncache, errorhandler, loginpageclass) self.instances = self.instance.instances self.servers = {} ! def handledefer(self, req, pathwords, argdict, session=None): """handles deferring the request to another server""" server = self.getserver(pathwords) *************** *** 422,441 **** return None if isinstance(server, SharedLoginAppServer): ! return server.handle(req, pathwords[1:], sharedsession=session) else: ! return server.handle(req, pathwords[1:]) ! def handle(self, req, pathwords): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): - # can't do self.processargs otherwise the other server won't be able to... if pathwords[0] in self.instances: session = self.sessioncache.getsession(req, self) if session.isopen: ! return self.handledefer(req, pathwords, session) else: return None else: ! argdict = self.processargs(self.instance, req) session = self.getsession(req, argdict) if session.isopen: --- 420,438 ---- return None if isinstance(server, SharedLoginAppServer): ! return server.handle(req, pathwords[1:], argdict, sharedsession=session) else: ! return server.handle(req, pathwords[1:], argdict) ! def handle(self, req, pathwords, argdict): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): if pathwords[0] in self.instances: session = self.sessioncache.getsession(req, self) if session.isopen: ! return self.handledefer(req, pathwords, session, argdict) else: return None else: ! argdict = self.processargs(self.instance, argdict) session = self.getsession(req, argdict) if session.isopen: *************** *** 469,473 **** class SharedLoginMiddleAppServer(SharedLoginAppServer, SharedLoginMultiAppServer): """a server that can be a parent *and* a child""" ! def handle(self, req, pathwords, sharedsession=None): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): --- 466,470 ---- class SharedLoginMiddleAppServer(SharedLoginAppServer, SharedLoginMultiAppServer): """a server that can be a parent *and* a child""" ! def handle(self, req, pathwords, argdict, sharedsession=None): """handles the request and returns a page object in response""" if self.shoulddefer(pathwords): *************** *** 475,483 **** if pathwords[0] in self.instances: session = self.sessioncache.getsession(req, self) ! return self.handledefer(req, pathwords, session) else: return None else: ! argdict = self.processargs(self.instance, req) exitapp = argdict.get('exitapp', 0) session = self.getsession(req, argdict, sharedsession) --- 472,480 ---- if pathwords[0] in self.instances: session = self.sessioncache.getsession(req, self) ! return self.handledefer(req, pathwords, argdict, session) else: return None else: ! argdict = self.processargs(self.instance, argdict) exitapp = argdict.get('exitapp', 0) session = self.getsession(req, argdict, sharedsession) |
From: <dav...@us...> - 2003-10-14 15:44:47
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1:/tmp/cvs-serv30391 Modified Files: dbtable.py Log Message: fixed typos (nonexistent variables) Index: dbtable.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/dbtable.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dbtable.py 14 Oct 2003 09:31:41 -0000 1.4 --- dbtable.py 14 Oct 2003 15:44:43 -0000 1.5 *************** *** 59,64 **** return "%s=%s" % (self.rowidcols[0], rowid) else: ! for n in range(len(self.rowid)): ! if type(rowid[n]) == unicode: rowid[n] = rowidpart[n].encode('iso8859') return "&".join(["%s=%s" % (self.rowidcols[n], rowid[n]) for n in range(len(self.rowidcols))]) --- 59,64 ---- return "%s=%s" % (self.rowidcols[0], rowid) else: ! for n in range(len(rowid)): ! if type(rowid[n]) == unicode: rowid[n] = rowid[n].encode('iso8859') return "&".join(["%s=%s" % (self.rowidcols[n], rowid[n]) for n in range(len(self.rowidcols))]) |
From: <dav...@us...> - 2003-10-14 09:39:51
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1:/tmp/cvs-serv30644 Modified Files: widgets.py Log Message: added code to support joining unicode & str together in ContentWidget.getcontentshtml - a normal join doesn't support this, so if we detect the condition, we convert everything to unicode also added support for refreshing a page to a different URL Index: widgets.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/widgets.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** widgets.py 25 Sep 2003 17:36:55 -0000 1.3 --- widgets.py 14 Oct 2003 09:39:48 -0000 1.4 *************** *** 88,92 **** return contents elif type(contents) in (tuple, list): ! return "".join([self.getcontentshtml(contentspart) for contentspart in contents]) elif hasattr(contents, "gethtml"): return contents.gethtml() --- 88,99 ---- return contents elif type(contents) in (tuple, list): ! contentslist = [self.getcontentshtml(contentspart) for contentspart in contents] ! # TODO: investigate ways to neaten this up while still preventing ASCII decoding error... ! typelist = [type(p) for p in contentslist] ! if unicode in typelist and str in typelist: ! for n in range(len(contentslist)): ! if type(contentslist[n]) == str: ! contentslist[n] = contentslist[n].decode('iso8859') ! return "".join(contentslist) elif hasattr(contents, "gethtml"): return contents.gethtml() *************** *** 213,216 **** --- 220,224 ---- underlinelinks=self.attribs.get('underlinelinks',1) refresh=self.attribs.get('refresh',None) + refreshurl=self.attribs.get('refreshurl',None) result = """ <html> *************** *** 221,226 **** <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">""" if refresh is not None: ! result += """ ! <meta http-equiv="Refresh" content="%s">""" % (refresh) # stylesheet info result += """ --- 229,236 ---- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">""" if refresh is not None: ! if refreshurl is None: ! result += """<meta http-equiv="Refresh" content="%d">""" % (refresh) ! else: ! result += """<meta http-equiv="Refresh" content="%d; URL=%s">""" % (refresh, refreshurl) # stylesheet info result += """ |
From: <dav...@us...> - 2003-10-14 09:38:31
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1:/tmp/cvs-serv30391 Modified Files: grid.py Log Message: added support for unicode text Index: grid.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/grid.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** grid.py 25 Sep 2003 17:36:55 -0000 1.3 --- grid.py 14 Oct 2003 09:38:25 -0000 1.4 *************** *** 195,198 **** --- 195,200 ---- if obj is None: text = '' + elif type(obj) == unicode: + text = obj.encode('iso8859') else: text = str(obj) |
From: <dav...@us...> - 2003-10-14 09:37:35
|
Update of /cvsroot/jtoolkit/jToolkit/widgets In directory sc8-pr-cvs1:/tmp/cvs-serv30224 Modified Files: form.py Log Message: added code to support passwords in SimpleForm - by default, anything with 'password' in the name Index: form.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/widgets/form.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** form.py 25 Aug 2003 12:16:45 -0000 1.2 --- form.py 14 Oct 2003 09:37:31 -0000 1.3 *************** *** 79,82 **** --- 79,84 ---- elif self.displaytype == 'update': return widgets.Input({'name':self.name, 'value':valuestr, 'style':style}, readonly=self.readonly) + elif self.displaytype == 'password': + return widgets.Input({'name':self.name, 'value':valuestr, 'style':style, 'type':'password'}, readonly=self.readonly) elif self.displaytype == 'text': return widgets.TextArea({'name':self.name, 'style':style, 'rows':self.rowspan}, readonly=self.readonly, contents=valuestr) *************** *** 192,195 **** --- 194,199 ---- for option in options: category.addoption(option, option) + elif name.lower().find('password') != -1: + category.setdisplayoptions(display=1,readonly=0,displaytype='password',alwaysallowblank=0) else: category.setdisplayoptions(display=1,readonly=0,displaytype='update',alwaysallowblank=0) |
From: <dav...@us...> - 2003-10-14 09:36:56
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv30126 Modified Files: server.py Log Message: added caching control also changed logic in argument parsing: was skipping StringFields if they were in multiple-argument lists... Index: server.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/server.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** server.py 29 Sep 2003 08:01:38 -0000 1.5 --- server.py 14 Oct 2003 09:36:49 -0000 1.6 *************** *** 194,197 **** --- 194,201 ---- def sendpage(self, req, thepage): """returns the page to the user""" + # disallow caching unless the user explicitly overrides this (per-server or per-page) + if not (getattr(self, 'allowcaching', 0) or getattr(thepage, 'allowcaching', 0)): + req.headers_out.add('Cache-Control', 'no-cache') + req.headers_out.add('Pragma', 'no-cache') if isinstance(thepage, widgets.Widget): # get the content type... *************** *** 231,235 **** # this only happens with multiple arguments, which we don't want value = value[0] ! elif hasattr(value, 'value'): # this is for a StringField from mod_python 3... value = value.value --- 235,239 ---- # this only happens with multiple arguments, which we don't want value = value[0] ! if hasattr(value, 'value'): # this is for a StringField from mod_python 3... value = value.value |
From: <dav...@us...> - 2003-10-14 09:34:10
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1:/tmp/cvs-serv29724 Modified Files: database.py Log Message: added error trace if type is unknown in dbrepr Index: database.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/database.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** database.py 25 Sep 2003 17:36:55 -0000 1.3 --- database.py 14 Oct 2003 09:34:06 -0000 1.4 *************** *** 232,235 **** --- 232,236 ---- return value.dbrepr() # otherwise try return repr(value) anyway + self.errorhandler.logerror("unknown type in dbrepr: value=%r, type=%r" % (value, type(value))) return repr(value) |
From: <dav...@us...> - 2003-10-14 09:31:46
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1:/tmp/cvs-serv29403 Modified Files: dbtable.py Log Message: added code to encode unicode in rowidparamstring Index: dbtable.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/dbtable.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dbtable.py 25 Sep 2003 17:36:55 -0000 1.3 --- dbtable.py 14 Oct 2003 09:31:41 -0000 1.4 *************** *** 56,61 **** --- 56,64 ---- """returns a param string (for a url) that matches the rowid""" if len(self.rowidcols) == 1: + if type(rowid) == unicode: rowid = rowid.encode('iso8859') return "%s=%s" % (self.rowidcols[0], rowid) else: + for n in range(len(self.rowid)): + if type(rowid[n]) == unicode: rowid[n] = rowidpart[n].encode('iso8859') return "&".join(["%s=%s" % (self.rowidcols[n], rowid[n]) for n in range(len(self.rowidcols))]) |
From: <dav...@us...> - 2003-10-14 09:31:02
|
Update of /cvsroot/jtoolkit/jToolkit/data In directory sc8-pr-cvs1:/tmp/cvs-serv29279 Modified Files: dates.py Log Message: changed errors to unique dates.ParseError so they can be easily detected Index: dates.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/data/dates.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dates.py 25 Sep 2003 17:36:55 -0000 1.3 --- dates.py 14 Oct 2003 09:30:58 -0000 1.4 *************** *** 41,44 **** --- 41,47 ---- days = mxDateTime.DateTimeDeltaFromDays + class ParseError(ValueError): + pass + class dateparser: """a simulated type which can parse strings into dates given a format""" *************** *** 52,56 **** """simulates a constructor call for this dateparser""" if len(args) <> 1: ! raise TypeError("dateparser takes exactly 1 argument.") return self.parse(args[0]) --- 55,59 ---- """simulates a constructor call for this dateparser""" if len(args) <> 1: ! raise ParseError("dateparser takes exactly 1 argument.") return self.parse(args[0]) *************** *** 59,63 **** match = self.r.match(formatteddate) if match is None: ! raise TypeError("cannot parse formatted date: "+repr(formatteddate)+" with format string: "+repr(self.format)) g = match.groupdict() for key, value in g.items(): --- 62,66 ---- match = self.r.match(formatteddate) if match is None: ! raise ParseError("cannot parse formatted date: "+repr(formatteddate)+" with format string: "+repr(self.format)) g = match.groupdict() for key, value in g.items(): *************** *** 89,93 **** pass else: ! raise TypeError("invalid AM/PM value: "+repr(ampm)+" in date "+repr(formatteddate)+" with format string: "+repr(self.format)) return date(Y,M,D,h,m,s) --- 92,96 ---- pass else: ! raise ParseError("invalid AM/PM value: "+repr(ampm)+" in date "+repr(formatteddate)+" with format string: "+repr(self.format)) return date(Y,M,D,h,m,s) |
From: <dav...@us...> - 2003-10-14 08:25:59
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv18595 Modified Files: __init__.py Log Message: factored out getserver which does the import of the instance etc. and creates a server also added error checking code into the import Index: __init__.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 29 Sep 2003 07:47:11 -0000 1.4 --- __init__.py 14 Oct 2003 08:25:55 -0000 1.5 *************** *** 19,22 **** --- 19,24 ---- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + import sys + # list of modules in this package __all__ = ["safeapache", "server", "session"] *************** *** 55,66 **** pass ! # handler is in here so that we can say PythonHandler jToolkit.web ! # (modpython automatically looks for handler in that module) ! def handler(req): ! """the standard handler which locates the instance, creates the server if neccessary, and hands off to it""" ! logtime('handler start: ' + req.uri) ! apache_options = req.get_options() ! modulename = apache_options['jToolkit.module'] ! instancename = apache_options['jToolkit.instance'] fullinstancename = modulename + "." + instancename if fullinstancename in servers: --- 57,62 ---- pass ! def getserver(modulename, instancename): ! """returns a server based on a given instance in a given module""" fullinstancename = modulename + "." + instancename if fullinstancename in servers: *************** *** 68,78 **** else: # this is equivalent to: from modulename import instancename ! module = __import__(modulename, globals(), locals(), [instancename]) # get the actual instance ! instance = getattr(module, instancename) # construct a server of the appropriate class using the instance server = instance.serverclass(instance) server.name = fullinstancename servers[fullinstancename] = server pathwords = filter(None, req.uri.split('/')) # split into bits, strip out empty strings logtime('calling server.handle: ' + req.uri) --- 64,95 ---- else: # this is equivalent to: from modulename import instancename ! try: ! module = __import__(modulename, globals(), locals(), [instancename]) ! except ImportError, importmessage: ! errormessage = "Error importing module %r: %s\nPython path is %r" \ ! % (modulename, importmessage, sys.path) ! raise ImportError(errormessage) # get the actual instance ! try: ! instance = getattr(module, instancename) ! except AttributeError: ! errormessage = "module %r has no attribute %r\nmodule is %r, attributes are %r\nPython path is %r" \ ! % (modulename, instancename, module, dir(module), sys.path) ! raise AttributeError(errormessage) # construct a server of the appropriate class using the instance server = instance.serverclass(instance) server.name = fullinstancename servers[fullinstancename] = server + return server + + # handler is in here so that we can say PythonHandler jToolkit.web + # (modpython automatically looks for handler in that module) + def handler(req): + """the standard handler which locates the instance, creates the server if neccessary, and hands off to it""" + logtime('handler start: ' + req.uri) + apache_options = req.get_options() + modulename = apache_options['jToolkit.module'] + instancename = apache_options['jToolkit.instance'] + server = getserver(modulename, instancename) pathwords = filter(None, req.uri.split('/')) # split into bits, strip out empty strings logtime('calling server.handle: ' + req.uri) |
From: <dav...@us...> - 2003-09-29 08:15:52
|
Update of /cvsroot/jtoolkit/jToolkit In directory sc8-pr-cvs1:/tmp/cvs-serv9097 Added Files: Makefile README Log Message: Added Makefile that just makes archives of the source, and README --- NEW FILE: Makefile --- VERSION=0.1 pysrc=*.py */*.py docsrc=COPYING Makefile README src=$(docsrc) $(pysrc) all: jToolkit-$(VERSION).tar.gz jToolkit-$(VERSION).zip MANIFEST: pkgname=jToolkit MANIFEST: @ls $(src) | sed s:^:$(pkgname)-$(VERSION)/: >MANIFEST @ls MANIFEST | sed s:^:$(pkgname)-$(VERSION)/: >>MANIFEST jToolkit-$(VERSION).tar.gz jToolkit-$(VERSION).zip: pkgname=jToolkit jToolkit-$(VERSION).tar.gz jToolkit-$(VERSION).zip: MANIFEST jToolkit-$(VERSION).tar.gz jToolkit-$(VERSION).zip: $(src) @(cd ..; ln -s $(pkgname) $(pkgname)-$(VERSION)) (rm -f $(pkgname)-$(VERSION).tar.gz) (cd ..; tar -czvf $(pkgname)/$(pkgname)-$(VERSION).tar.gz `cat $(pkgname)/MANIFEST`) (rm -f $(pkgname)-$(VERSION).zip) (cd ..; zip -r $(pkgname)/$(pkgname)-$(VERSION).zip `cat $(pkgname)/MANIFEST`) @(cd ..; rm $(pkgname)-$(VERSION)) --- NEW FILE: README --- jToolkit README jToolkit is a Python web application framework built on modpython and Apache. It is aimed at dynamically generated pages rather than mostly-static pages (for which there are templating solutions). Pages can be produced using a variety of widgets. It handles sessions and database connections. jToolkit has already been deployed in working systems in Linux and in Windows. The source code is licensed under the GPL license. See COPYING for more information. You can get more information on jToolkit at http://jtoolkit.sourceforge.net/ |
From: <dav...@us...> - 2003-09-29 08:08:09
|
Update of /cvsroot/jtoolkit/jToolkit/demo In directory sc8-pr-cvs1:/tmp/cvs-serv7722 Modified Files: helloworld.py Log Message: took out now-not-required localization info... Index: helloworld.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/demo/helloworld.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** helloworld.py 25 Sep 2003 18:18:38 -0000 1.1 --- helloworld.py 29 Sep 2003 08:07:36 -0000 1.2 *************** *** 31,35 **** """the configuration parameters for a hello world server""" serverclass = HelloWorldServer - localedir = "/share/sjsoft/code/jSuite.py/localize" - localedomains = ['jToolkit', 'jLogbook.python'] --- 31,33 ---- |
From: <dav...@us...> - 2003-09-29 08:03:10
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv6431 Modified Files: server.py Log Message: added support for operation without localedir and/or localedomains (so you can run a server without doing any localization) Index: server.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/server.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** server.py 29 Sep 2003 07:12:20 -0000 1.4 --- server.py 29 Sep 2003 08:01:38 -0000 1.5 *************** *** 161,167 **** else: self.errorhandler = errorhandler ! self.languagelist = localize.getinstalledlanguages(self.instance.localedir) ! self.languagenames = localize.getlanguagenames(self.languagelist) ! self.translation = localize.translation(self.instance.localedomains, self.instance.localedir, self.languagelist) if hasattr(self.instance, 'defaultlanguage'): self.defaultlanguage = self.instance.defaultlanguage --- 161,177 ---- else: self.errorhandler = errorhandler ! if hasattr(self.instance, 'localedir'): ! self.localedir = self.instance.localedir ! self.languagelist = localize.getinstalledlanguages(self.localedir) ! self.languagenames = localize.getlanguagenames(self.languagelist) ! else: ! self.localedir = None ! self.languagelist = [] ! self.languagenames = {} ! if hasattr(self.instance, 'localedomains'): ! self.localedomains = self.instance.localedomains ! else: ! self.localedomains = [] ! self.translation = localize.translation(self.localedomains, self.localedir, self.languagelist) if hasattr(self.instance, 'defaultlanguage'): self.defaultlanguage = self.instance.defaultlanguage *************** *** 234,238 **** else: languagelist = [language] + self.languagelist ! return localize.translation(self.instance.localedomains, self.instance.localedir, languagelist) def localize(self, message): --- 244,248 ---- else: languagelist = [language] + self.languagelist ! return localize.translation(self.localedomains, self.localedir, languagelist) def localize(self, message): |
From: <dav...@us...> - 2003-09-29 07:58:17
|
Update of /cvsroot/jtoolkit/jToolkit In directory sc8-pr-cvs1:/tmp/cvs-serv5470 Modified Files: localize.py Log Message: added support for empty language list when choosing default language Index: localize.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/localize.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** localize.py 25 Sep 2003 17:36:55 -0000 1.3 --- localize.py 29 Sep 2003 07:58:02 -0000 1.4 *************** *** 107,120 **** except ValueError: defaultlocale, defaultencoding = None, None ! if currentlocale is not None: ! if currentlocale in languagelist: return currentlocale ! elif reducelocale(currentlocale) in languagelist: ! return reducelocale(currentlocale) ! if defaultlocale is not None: ! if defaultlocale in languagelist: return defaultlocale ! elif reducelocale(defaultlocale) in languagelist: ! return reducelocale(defaultlocale) ! return languagelist[0] --- 107,128 ---- except ValueError: defaultlocale, defaultencoding = None, None ! if len(languagelist) > 0: ! if currentlocale is not None: ! if currentlocale in languagelist: ! return currentlocale ! elif reducelocale(currentlocale) in languagelist: ! return reducelocale(currentlocale) ! if defaultlocale is not None: ! if defaultlocale in languagelist: ! return defaultlocale ! elif reducelocale(defaultlocale) in languagelist: ! return reducelocale(defaultlocale) ! return languagelist[0] ! else: ! # if our language list is empty, we'll just ignore it ! if currentlocale is not None: return currentlocale ! elif defaultlocale is not None: return defaultlocale ! return None |
From: <dav...@us...> - 2003-09-29 07:47:27
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv3226 Modified Files: __init__.py Log Message: added code to disable thread time logging unless needed... Index: __init__.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __init__.py 25 Sep 2003 17:36:55 -0000 1.3 --- __init__.py 29 Sep 2003 07:47:11 -0000 1.4 *************** *** 26,41 **** servers = {} ! import os, thread, time ! logfilename = 'C:\\Temp\\threads.log' ! def logtime(message): ! osid = os.getpid() ! threadid = thread.get_ident() ! t = time.time() ! ms = int((t - int(t))*1000.0) ! timestr = time.strftime('%Y-%m-%d %H:%M:%S') + '.%03d' % ms ! f = open(logfilename, 'a') ! f.write('%s: pid %r tid %r: %s\n' % (timestr, osid, threadid, message)) ! f.close() # handler is in here so that we can say PythonHandler jToolkit.web --- 26,57 ---- servers = {} ! logtimes = 0 ! if logtimes: ! import os, time ! try: ! import thread ! except ImportError: ! # pretend we have threads if we don't ! def thread_get_ident(): ! return 0 ! class blank: pass ! thread = blank() ! thread.get_ident = thread_get_ident ! logfilename = '/tmp/threads.log' ! ! def logtime(message): ! osid = os.getpid() ! threadid = thread.get_ident() ! t = time.time() ! ms = int((t - int(t))*1000.0) ! timestr = time.strftime('%Y-%m-%d %H:%M:%S') + '.%03d' % ms ! f = open(logfilename, 'a') ! f.write('%s: pid %r tid %r: %s\n' % (timestr, osid, threadid, message)) ! f.close() ! else: ! def logtime(message): ! """don't log anything as we aren't in logtimes mode""" ! pass # handler is in here so that we can say PythonHandler jToolkit.web |
From: <dav...@us...> - 2003-09-29 07:12:35
|
Update of /cvsroot/jtoolkit/jToolkit/web In directory sc8-pr-cvs1:/tmp/cvs-serv30459 Modified Files: server.py Log Message: added missing blank line Index: server.py =================================================================== RCS file: /cvsroot/jtoolkit/jToolkit/web/server.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** server.py 25 Sep 2003 17:36:55 -0000 1.3 --- server.py 29 Sep 2003 07:12:20 -0000 1.4 *************** *** 227,230 **** --- 227,231 ---- return value.decode('iso8859') return value + def gettranslation(self, language): """returns a translation object for the given language (or default if language is None)""" |
From: <dav...@us...> - 2003-09-25 18:18:43
|
Update of /cvsroot/jtoolkit/jToolkit/demo/html In directory sc8-pr-cvs1:/tmp/cvs-serv20907/html Added Files: .htaccess index.htm Log Message: added basic hello world demo --- NEW FILE: .htaccess --- SetHandler python-program PythonHandler jToolkit.web PythonOption jToolkit.module jToolkit.demo.helloworld PythonOption jToolkit.instance HelloWorldConfig PythonDebug On --- NEW FILE: index.htm --- |