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 full-size slide

  2. whoami
    Free software developer

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

    contributore: uwsgi, LibreOffice, ...

    View full-size slide

  3. In Django 1.8

    View full-size 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 full-size 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 full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

  9. In Django 1.9

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  14. Contribuire a Django è possibile!

    View full-size slide

  15. Indovina chi?

    View full-size slide

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

    View full-size slide

  17. Django Fellowship program
    [...]

    reviewing and merging pull requests

    triaging tickets on Trac

    helping new Django contributors land patches
    and learn our philosophy

    View full-size slide

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

    View full-size slide

  19. Come si contribuisce a Django?

    View full-size slide

  20. 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 full-size slide

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

    View full-size slide

  22. Ticket accettato
    Triage stage: Unreviewed -> Accepted

    View full-size slide

  23. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. 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 full-size slide

  29. 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 full-size slide

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

    View full-size slide

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

    View full-size slide