Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cosa mi entusiasma nelle prossime release di Django

Cosa mi entusiasma nelle prossime release di Django

Alcune piccole feature inserite nelle prossime release di Django e una piccola guida su come iniziare a proporne di proprie.

Riccardo Magliocchetti

April 17, 2015
Tweet

More Decks by Riccardo Magliocchetti

Other Decks in Programming

Transcript

  1. Cosa mi entusiasma nelle
    prossime release di Django
    Riccardo Magliocchetti
    DjangoVillage 2015

    View Slide

  2. whoami
    Free software developer

    Maintainer: django-admin-bootstrapped,
    bootchart2, ...

    contributore: uwsgi, LibreOffice, ...

    View Slide

  3. In Django 1.8

    View Slide

  4. Poor man's multi tenancy
    Fixed #15089 -- Allowed contrib.sites to lookup the current site
    based on request.get_host()
    get_current_site() will now lookup the current site based on
    request.get_host() if the SITE_ID setting is not defined.
    https://github.com/django/django/commit/32c7d3c061b83e9206
    ef2bf13fbc302a1998f317

    View Slide

  5. Poor man's multi tenancy:
    threadlocals
    from threading import local
    _tlocals = local()
    class ThreadLocalMiddleware(object):
    def process_request(self, request):
    _tlocals.request = request
    def get_tls_request():
    return getattr(_tlocals, "request")

    View Slide

  6. Poor man's multi tenancy:
    settings.py
    SITE_ID = None
    MIDDLEWARE_CLASSES += (
    'threadlocals.ThreadLocalMiddleware'
    )

    View Slide

  7. Poor man's multi tenancy: your code
    from django.contrib.sites.shortcuts
    import get_current_site
    from threadlocals import get_tls_request
    request = get_tls_request()
    site = get_current_site(request)

    View Slide

  8. Poor man's multi tenancy: profit!
    Collegate le vostre configurazioni a
    django.contrib.sites.models.Site

    View Slide

  9. In Django 1.9

    View Slide

  10. Stop alle window in admin! (DIY)
    Fixed #22894 -- Made admin add related/raw ID
    fields widgets customizable
    Fixed #24405 -- Made admin related object
    JavaScript overridable

    View Slide

  11. Lista applicazioni nell'admin
    Fixed #24553 -- Added the list of applications to
    the context of admin views

    View Slide

  12. View Slide

  13. Rework loading template
    Fixed #15053 -- Make templates more reusable
    by Improving template loading algorithm to avoid
    extending infinite recursion
    Thanks to Preston Timmons

    View Slide

  14. Temi facili
    templates/admin/base.html:
    {% extends "admin/base.html" %}
    {% block title %}
    Cambio solo il title
    {% endblock %}

    View Slide

  15. Contribuire a Django è possibile!

    View Slide

  16. Indovina chi?

    View Slide

  17. E` Tim!
    Tim Graham - Django Fellow
    Donate!
    https://www.djangoproject.com/fundraising/

    View Slide

  18. Django Fellowship program
    [...]

    reviewing and merging pull requests

    triaging tickets on Trac

    helping new Django contributors land patches
    and learn our philosophy

    View Slide

  19. Quindi?
    C'è qualcuno pagato per aiutarvi a contribuire

    View Slide

  20. Come si contribuisce a Django?

    View Slide

  21. Aprire un Ticket
    https://code.djangoproject.com
    Cerchiamo tra i ticket già inseriti duplicati :)
    Cosa vogliamo fare e perchè
    NON scrivo una riga di codice

    View Slide

  22. Primo feedback
    Utile? Duplicato?
    Richiede discussione in lista django-developers?
    Riguarda la ux? UI/UX

    View Slide

  23. Ticket accettato
    Triage stage: Unreviewed -> Accepted

    View Slide

  24. Preparo l'environment
    Fork su github
    git clone
    cd django
    git remote add upstream
    https://github.com/django/django.git
    git checkout ­b ticketNumero
    virtualenv masterenv
    ./masterenv/bin/pip install
    ~/path/repo/django

    View Slide

  25. Codice in github
    Commit, commit, commit, push!
    Pull request!

    View Slide

  26. Review
    Ci sono cose da sistemare? patch needs
    improvement
    Manca doc? needs documentation
    Mancano i test? needs tests

    View Slide

  27. Reitera
    git push ­f vostrorepo vostrobranch
    Fatte le modifiche: tolgo patch needs
    improvement

    View Slide

  28. Evitare il ping-pong
    isort filecambiato.py ­­diff
    flake8 filecambiato.py
    cd docs; make html
    cd tests; PYTHONPATH=.. python
    runtests.py

    View Slide

  29. Test tricks
    # se ho cambiato a html / js
    # installate ultima versione selenium
    runtests.py ­­selenium
    # Trova da quando miotest viene
    spaccato
    runtests.py ­­bisect miotest
    # Trova un test che spacca miotest
    runtests.py ­­pair miotest

    View Slide

  30. Test like a pro
    djangocore-box: tutte le versioni di python, tutti i
    db in vm
    https://github.com/jphalip/djangocore-box
    djangocore-docker: pgsql + python in un container
    https://github.com/PirosB3/djangocore-docker

    View Slide

  31. Reference
    https://docs.djangoproject.com/en/1.8/internals
    /contributing/writing-code/submitting-patches/

    View Slide

  32. Happy Hacking
    Riccardo Magliocchetti
    [email protected]
    @rmistaken
    http://menodizero.it
    https://github.com/xrmx

    View Slide