def match(self, url, datetime=None): """ Return 1/0 depending on whether the Cookie matches the given url or not. datetime is used to check for expiration in case the Cookie is a temporary one. It defaults to the current date/time. """ url = URL.URL(url) if self.expires is not None: if datetime is None: datetime = DateTime.now() if self.expires < datetime: if _debug: print 'expired' return 0 if TextTools.prefix(url.path, (self.path, )) is None: if _debug: print 'path does not match' return 0 if TextTools.suffix(url.host, (self.domain, )) is None: if _debug: print 'domain does not match' return 0 return 1
def match(self, url, datetime=None): """ Return 1/0 depending on whether the Cookie matches the given url or not. datetime is used to check for expiration in case the Cookie is a temporary one. It defaults to the current date/time. """ url = URL.URL(url) if self.expires is not None: if datetime is None: datetime = DateTime.now() if self.expires < datetime: if _debug: print 'expired' return 0 if TextTools.prefix(url.path, (self.path,)) is None: if _debug: print 'path does not match' return 0 if TextTools.suffix(url.host, (self.domain,)) is None: if _debug: print 'domain does not match' return 0 return 1