pythondotorg Documentation

repository·main·Indexed 23 days ago

https://github.com/python/pythondotorg

The codebase for python.org, the official website for the Python programming language. This Django application utilizes PostgreSQL, Redis, and Celery. Documentation covers the blogs app for RSS feed management, the downloads app for managing Python software releases and redirects, CMS initial data seeding via management commands, and infrastructure configuration for Fastly CDN and NGWAF using Terraform.

Tokens
15.9K
Snippets
34
Records
99
Agent score
82%

What's inside pythondotorg

  1. Overview of Docker services

    main

    The development environment is orchestrated via docker-compose.yml and consists of five primary services:

    • postgres: PostgreSQL 15.3 database.
    • redis: Redis 7 used for caching and as a Celery broker.
    • web: The Django development server, accessible on port 8000.
    • worker: A Celery worker equipped with the django-celery-beat scheduler.
    • static: Handles the SCSS compilation and the static asset pipeline.
  2. Review Termination and Code of Conduct requirements

    main

    Sponsors must adhere to specific behavioral and contractual termination clauses:

    • Termination Rights:
      • Either party can terminate with 60 days' written notice.
      • Termination for material breach (if not cured within 15 days).
      • Mutual written consent.
      • Termination if Sponsor information violates third-party rights.
      • The PSF has a unilateral right to terminate if the sponsorship is detrimental to the reputation of the PSF or its Programs.
    • Code of Conduct: Sponsors and their representatives must comply with the Python Software Foundation Code of Conduct and/or the PyCon Code of Conduct. The PSF reserves the right to eject any Sponsor or representative violating these standards.
  3. How Supernavs work

    main

    A Supernav is a large block of text or markup used in main navigation dropdowns. They are implemented as specially named boxes following the naming convention supernav-* (e.g., templates/downloads/supernav.html).

    Most supernavs are updated automatically via Django signals. By convention, an application should have a template named supernav.html. For example, saving a published Release triggers a signal that updates the supernav-python-downloads box with the latest Python 2 and Python 3 releases. The markup is structured to work with OS-detection JavaScript to show appropriate download links based on the user's browser.

  4. Structure of the Sponsorship Agreement template

    main

    The sponsorship agreement is a Django-based Markdown template used to generate legal contracts for the Python Software Foundation (PSF). It uses Django template tags to inject dynamic data for both standard agreements and renewals.

    Key components include:

    • Signature Block: Captures the Effective Date, PSF representative details, and Sponsor details (Name and Incorporation Location).
    • Exhibit A: Defines the terms of the sponsorship, including the sponsorship level, payment details, and specific benefits.
    • Conditional Logic: Uses {% if renewal %} to toggle between a standard agreement and a renewal agreement, and {% if legal_clauses %} to append additional legal provisions.
  5. Review Intellectual Property and Licensing terms

    main

    The agreement defines how intellectual property (IP) is handled between the Sponsor and the PSF:

    • PSF Ownership: The PSF owns all PSF information, including logos, trademarks, and copyrights.
    • PSF License to Sponsor: The PSF grants a limited, non-exclusive license to use PSF Intellectual Property (name, acronym, logo) solely for promoting the Sponsor's sponsorship. The PSF may review and approve uses in advance.
    • Sponsor License to PSF: The Sponsor grants a limited, non-exclusive license to use Sponsor Intellectual Property (names, trademarks, copyrights) solely to identify the Sponsor as a sponsor.
    • Post-Termination: Upon expiration or termination, neither party may use the other's name, marks, or logos without express prior written authorization.
  6. Use Boxes for reusable HTML markup

    main
    Boxes are reusable bits of HTML markup used throughout the site for elements like sidebars or rich landing page sections. This prevents the need to edit large, cumbersome content textareas. Some boxes are "special boxes" that are automatically rebuilt using templates (see Supernavs).
  7. Understand CI requirements and enforcement

    main

    GitHub Actions runs on every push and pull request. To be eligible for merging, your PR must pass all CI checks, which include:

    • Migration Check: Verifies there are no ungenerated migrations using makemigrations --check --dry-run.
    • Test Suite: Runs the full test suite.
    • Test Coverage: Enforces a 75% minimum test coverage threshold.

    PRs that fail any of these checks will not be merged.

  8. Manage site navigation with Sitetree

    main

    Navigation on the site is managed using the django-sitetree application. When defining URLs for navigation items, you have two options in the Additional Settings fieldset:

    1. URL as pattern: If checked, the URL is validated against the URLs defined by the Django applications.
    2. Relative/Absolute URLs: If the URL as pattern option is unchecked, you can enter standard relative or absolute URLs.

    Note that the site uses a fall-through routing system for Pages, so you cannot accidentally override an existing Django URL with a Page.

  9. Understand the Sponsorship Agreement renewal process

    main

    The sponsorship agreement template supports a renewal workflow via a renewal boolean flag.

    When renewal is true, the agreement logic changes to:

    1. Replace Exhibit A: The existing Exhibit A is replaced with a new version.
    2. Automatic Renewal Notice: Approval and incorporation of the new exhibit serves as written notice from the Sponsor to the Python Software Foundation (PSF) to continue the terms for an additional year and to contribute the new Sponsorship Payment specified in the new Exhibit A.
    {% if renewal %}
    1. [**Replacement of the Exhibit**]{.underline} Exhibit A to the Sponsorship Agreement is replaced with Exhibit A below.
    
    1. [**Renewal**]{.underline} Approval and incorporation of this new exhibit with the previous Sponsor Benefits shall be considered written notice by Sponsor to the PSF that you wish to continue the terms of the Sponsorship Agreement for an additional year and to contribute the new Sponsorship Payment specified in Exhibit A, beginning on the Effective Date, as contemplated by Section 6 of the Sponsorship Agreement.
    {% else %}
  10. Understand the Sponsors application structure

    main

    The Sponsors app is a complex system used to manage PSF Sponsors and Sponsorships. It is organized into several model groups based on context:

    • sponsorship.py: Manages the Sponsorship model and configuration for applications (programs, packages, benefits).
    • benefits.py: Configures benefits, including models that enforce asset requirements or maximum quantities.
    • assets.py: Configures the types of assets a benefit can have.
    • sponsors.py: Manages the Sponsor model, including contact information and assigned benefits.
    • notifications.py: Handles configurable sponsor notifications via the admin.
    • contract.py: Manages the Contract model used to generate final contract documents.
  11. Prepare contributions for python.org

    main

    Before submitting a pull request to the python.org repository, you must ensure your changes meet the project's quality standards. Follow these steps:

    1. Run Tests: Execute make test to ensure the test suite passes. CI enforces a minimum of 75% test coverage.
    2. Lint and Format: Run make lint and make fmt to ensure code style compliance.
    3. Check Migrations: Run make migrations to check for any missing database migrations. CI will fail if ungenerated migrations are detected.
    4. Add Tests: Ensure you have written tests for any new or modified code.
    make test
    make lint
    make fmt
    make migrations
  12. Clone and sync the Pythondotorg repository

    main

    To start developing, fork the repository on GitHub and clone it to your local machine. To stay current with the upstream repository, add it as a remote and merge changes regularly.

    # Clone your fork
    git clone git@github.com:YOUR-USERNAME/pythondotorg.git
    
    # Add upstream remote and sync
    git remote add upstream https://github.com/python/pythondotorg
    git checkout main
    git fetch upstream 
    git merge upstream/main