(self, tup, request)
| 1485 | return cookie_tuples |
| 1486 | |
| 1487 | def _cookie_from_cookie_tuple(self, tup, request): |
| 1488 | # standard is dict of standard cookie-attributes, rest is dict of the |
| 1489 | # rest of them |
| 1490 | name, value, standard, rest = tup |
| 1491 | |
| 1492 | domain = standard.get("domain", Absent) |
| 1493 | path = standard.get("path", Absent) |
| 1494 | port = standard.get("port", Absent) |
| 1495 | expires = standard.get("expires", Absent) |
| 1496 | |
| 1497 | # set the easy defaults |
| 1498 | version = standard.get("version", None) |
| 1499 | if version is not None: |
| 1500 | try: |
| 1501 | version = int(version) |
| 1502 | except ValueError: |
| 1503 | return None # invalid version, ignore cookie |
| 1504 | secure = standard.get("secure", False) |
| 1505 | # (discard is also set if expires is Absent) |
| 1506 | discard = standard.get("discard", False) |
| 1507 | comment = standard.get("comment", None) |
| 1508 | comment_url = standard.get("commenturl", None) |
| 1509 | |
| 1510 | # set default path |
| 1511 | if path is not Absent and path != "": |
| 1512 | path_specified = True |
| 1513 | path = escape_path(path) |
| 1514 | else: |
| 1515 | path_specified = False |
| 1516 | path = request_path(request) |
| 1517 | i = path.rfind("/") |
| 1518 | if i != -1: |
| 1519 | if version == 0: |
| 1520 | # Netscape spec parts company from reality here |
| 1521 | path = path[:i] |
| 1522 | else: |
| 1523 | path = path[:i+1] |
| 1524 | if len(path) == 0: path = "/" |
| 1525 | |
| 1526 | # set default domain |
| 1527 | domain_specified = domain is not Absent |
| 1528 | # but first we have to remember whether it starts with a dot |
| 1529 | domain_initial_dot = False |
| 1530 | if domain_specified: |
| 1531 | domain_initial_dot = bool(domain.startswith(".")) |
| 1532 | if domain is Absent: |
| 1533 | req_host, erhn = eff_request_host(request) |
| 1534 | domain = erhn |
| 1535 | elif not domain.startswith("."): |
| 1536 | domain = "."+domain |
| 1537 | |
| 1538 | # set default port |
| 1539 | port_specified = False |
| 1540 | if port is not Absent: |
| 1541 | if port is None: |
| 1542 | # Port attr present, but has no value: default to request port. |
| 1543 | # Cookie should then only be sent back on that port. |
| 1544 | port = request_port(request) |
no test coverage detected