def __init__(self, name, value, expires=None, path=None, domain=None, secure=None): """ Create a Netscape cookie for name with the given value. If expires is given, the cookie will be a temporary cookie which expires after a certain amount of time. expires may be given as integer (seconds relative to the current time), DateTime instance (absolute date/time) or RelativeDateTime instance (relative date/time to current time). path, domain, secure work according to the Netscape specification. """ self.name = name self.value = value if expires is not None: # Long living cookie if isinstance(expires, DateTime.DateTimeType): self.expires = expires.gmtime() elif isinstance(expires, DateTime.RelativeDateTime): self.expires = DateTime.gmtime() + expires else: self.expires = DateTime.gmtime() + \ expires * DateTime.oneSecond if path: self.path = path if domain: self.domain = domain if secure: self.secure = 1
def write(self): r = self.cnn.query( """ INSERT INTO test (kase, name, start_time, elapsed_time, username, hostname, process_info_start, process_info_end) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') """ % (self.kase , self.values["name"] , str(DateTime.gmtime(self.values["start_time"]))[0:19] , self.values["elapsed_time"] , self.username , self.hostname , self.Text2SQLText(self.values["process_info_start"]) , self.Text2SQLText(self.values["process_info_end"]))) return int(r)
def __init__(self, description, results): """construct with the description fetched from a database cursor and with the result rows from a query""" data = [] for result in results: row = {} for item, desc in map(None, result, description): if desc[1] == 'DATE': if item is not None: item = DateTime.gmtime(float(item)) elif desc[1] == 'RAW': item = str(item) row[string.lower(desc[0])] = item data.append(row) self.data = tuple(data)