Without Django. applying django principles to non django projects

Similar documents
Django urls Django Girls Tutorial

29-27 May 2013 CERN WEB FRAMEWORKS. Adrian Mönnich

EXPERIENCES MOVING FROM DJANGO TO FLASK

HOW TO FLASK. And a very short intro to web development and databases

Tomasz Szumlak WFiIS AGH 23/10/2017, Kraków

kiss.py Documentation

Quick housekeeping Last Two Homeworks Extra Credit for demoing project prototypes Reminder about Project Deadlines/specifics Class on April 12th Resul

Building Web Applications

django-cms-search Documentation

Python web frameworks

web frameworks design comparison draft - please help me improve it focus on Model-View-Controller frameworks


LECTURE 14. Web Frameworks

A Sample Approach to your Project

Let s Talk About Templates. Armin

CSCI 1320 Creating Modern Web Applications. Content Management Systems

LECTURE 14. Web Frameworks

Django Part II SPARCS 11 undead. Greatly Inspired by SPARCS 10 hodduc

webkitpony Documentation

Theming with Twig in Drupal 8. John Jennings Developer, Johnson & Johnson

Django-Style Flask. Cody Lee SCALE12x Feb 22, git clone

Building a Python Flask Website A beginner-friendly guide

The Pyramid Web Application Development Framework

CIS192 Python Programming

MIT AITI Python Software Development Lab DJ1:

Django Admin Sortable Documentation

Google & the Cloud. GData, Mashup Editor, AppEngine. Gregor Hohpe Software Engineer Google, Inc. All rights reserved,

Flask Web Development Course Catalog

The Swiss-Army Knife for Python Web Developers. Armin Ronacher

TailorDev Contact Documentation

Diving into Big Data Workshop

CSE 115. Introduction to Computer Science I

Django PAM Documentation

SAURASHTRA UNIVERSITY

Django EL(Endless) Pagination Documentation

The State of Python. and the web. Armin Ronacher

Django. Jinja2. Aymeric Augustin DjangoCong 2016

South Africa Templates.

django-amp-tools Documentation Release latest

CIS192 Python Programming

Buzzy Documentation. Release 0. Sebastian Pawluś

The Django Web Framework Part II. Hamid Zarrabi-Zadeh Web Programming Fall 2013

Course Title: Python + Django for Web Application

HTML 5 Form Processing

SYMFONY2 WEB FRAMEWORK

django-sekizai Documentation

Building Scalable Web Apps with Python and Google Cloud Platform. Dan Sanderson, April 2015

DIGIT.B4 Big Data PoC

Flask-Testing Documentation

Python Schema Generator Documentation

Unit 3 - Week 2 lectures: Building your webapp

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

django-renderit Documentation

20486: Developing ASP.NET MVC 4 Web Applications

Django-CSP Documentation

micawber Documentation

Nick Terkay CSCI 7818 Web Services 11/16/2006

kaleo Documentation Release 1.5 Eldarion

django-subdomains Documentation

Webdev: Building Django Apps. Ryan Fox Andrew Glassman MKE Python

django-xross Documentation

WeChat Adobe Campaign Integration - User Guide

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. TurboGears

django-private-chat Documentation

Flask-Plugins Documentation

[PACKT] open source^ Kohana 3.0. Beginner's Guide. Develop professional web applications with Kohana. Jason D. Straughan

Google App Engine Using Templates

Course 20486B: Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 4 Web Applications

Rapid Development with Django and App Engine. Guido van Rossum May 28, 2008

Django IPRestrict Documentation

ASP.NET MVC Training

Django with Python Course Catalog

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course

DATABASE SYSTEMS. Introduction to web programming. Database Systems Course, 2016

Developing ASP.Net MVC 4 Web Application

colab Documentation Release 2.0dev Sergio Oliveira

Ninja Typers Web Application Design Document By Marvin Farrell C

Scout Documentation. Release Charles Leifer

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS

Front End Programming

Contents. 1. What is otree? 2. The Shell and Python. 3. Example: simple questionnaire. 4. Example: public goods game. 5. Test bots.

20486: Developing ASP.NET MVC 4 Web Applications (5 Days)

SAURASHTRA UNIVERSITY

Software Test Plan Version 1.0

django-conduit Documentation

Moving to a Sustainable Web Development Environment for Library Web Applications

django-generic-filters Documentation

Developing ASP.NET MVC 4 Web Applications

Building a Django Twilio Programmable Chat Application

Summary. 1. Page 2. Methods 3. Helloworld 4. Translation 5. Layout a. Object b. Table 6. Template 7. Links. Helloworld. Translation Layout.

django-avatar Documentation

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

LECTURE 13. Intro to Web Development

Helpline No WhatsApp No.:

django-celery Documentation

django simple pagination Documentation

django-avatar Documentation

DJOAuth2 Documentation

widgets, events, layout loosely similar to Swing test browser, or plugin for testing with real browser on local system

Transcription:

Without Django applying django principles to non django projects

I Love Django Using Django since the very first release I love the templates (so much that I rewrote the templating engine twice) Often forcing myself not to use it because it does not fit.

Solace Werkzeug WSGI Jinja2 Templating SQLAlchemy Database http://opensource.plurk.com/solace/

views.py from solace.templating import render_template from solace.models import Tag def tags(request): """Shows the tag cloud.""" tags = Tag.query.filter( (Tag.tagged > 0) & (Tag.locale == request.view_lang) ).order_by(tag.tagged.desc()).limit(40).all() tags.sort(key=lambda x: x.name.lower()) return render_template('kb/tags.html', tags=tags)

views.py from solace.templating import render_template from solace.models import Tag def tags(request): """Shows the tag cloud.""" tags = list(tag.objects.filter( tagged gt=0, locale=str(request.view_lang) ).order_by(' tagged')[:40]) tags.sort(key=lambda x: x.name.lower()) return render_template('kb/tags.html', tags=tags)

models.py class UserQuery(Query): def active_in(self, locale): ua = user_activities.c return self.filter(user.id.in_(select([ua.user_id], ua.locale == locale))) class User(RemoteObject): query = session.query_property(userquery)...

models.py class UserManager(models.DatabaseManager): def active_in(self, locale): # not sure if that works... q = UserActivities.objects.filter_by(locale=str(locale)) return self.filter(user in=q) class User(models.Model, RemoteObject): objects = UserManager()...

{% extends 'layout.html' %} {% from 'kb/_boxes.html' import render_topics, render_topic_tabs %} {% set page_title = _('Overview') %} {% block html_head %} {{ super() }} <link rel="alternate" href="{{ url_for('kb.overview_feed', order_by=order_by) }}" type="application/atom+xml"> {% endblock %} {% block body %} <h1>{{ page_title }}</h1> <div class="explanation"> <p>{% trans %} This is an overview of some of the newest topics here on Solace. You can view other topics grouped by activity, votes and hotness. {% endtrans %} </div> {{ render_topic_tabs('kb.overview', order_by) }} {{ render_topics(topics) }} {{ pagination }} {% endblock %}

{% extends 'layout.html' %} {% from 'kb/_boxes.html' import render_topics, render_topic_tabs %} {% set page_title = _('Overview') %} {% block html_head %} {{ super() }} <link rel="alternate" href="{{ url_for('kb.overview_feed', order_by=order_by) }}" type="application/atom+xml"> {% endblock %} {% block body %} <h1>{{ page_title }}</h1> <div class="explanation"> <p>{% trans %} TEH SYNTAX! This is an overview of some of the newest topics here on Solace. You can view other topics grouped by activity, votes and hotness. {% endtrans %} </div> {{ render_topic_tabs('kb.overview', order_by) }} {{ render_topics(topics) }} {{ pagination }} {% endblock %}

{% extends 'layout.html' %} {% from 'kb/_boxes.html' import render_topics, render_topic_tabs %} {% set page_title = _('Overview') %} {% block html_head %} {{ super() }} <link rel="alternate" href="{{ url_for('kb.overview_feed', order_by=order_by) }}" type="application/atom+xml"> {% endblock %} {% block body %} <h1>{{ page_title }}</h1> <div class="explanation"> <p>{% trans %} template tags rendering templates This is an overview of some of the newest topics here on Solace. You can view other topics grouped by activity, votes and hotness. {% endtrans %} </div> {{ render_topic_tabs('kb.overview', order_by) }} {{ render_topics(topics) }} {{ pagination }} {% endblock %}

{% extends 'layout.html' %} {% from 'kb/_boxes.html' import render_topics, render_topic_tabs %} {% set page_title = _('Overview') %} {% block html_head %} {{ super() }} <link rel="alternate" href="{{ url_for('kb.overview_feed', order_by=order_by) }}" type="application/atom+xml"> {% endblock %} {% block body %} <h1>{{ page_title }}</h1> <div class="explanation"> URL Reversing <p>{% trans %} This is an overview of some of the newest topics here on Solace. You can view other topics grouped by activity, votes and hotness. {% endtrans %} </div> {{ render_topic_tabs('kb.overview', order_by) }} {{ render_topics(topics) }} {{ pagination }} {% endblock %}

Signals: from solace.signals import after_request_shutdown, \ before_response_sent, after_cursor_executed # get rid of the session at the end of the request after_request_shutdown.connect(session.remove) # adds query debug headers for unittest if enabled before_response_sent.connect(add_query_debug_headers) # tracks the number of queries on the request object after_cursor_executed.connect(request_track_query)

Why not Django? Nice looking code when starting the project Often ugly hacks to keep it running that do not look nice I m obsessed with nice looking code Replacing contrib apps with self written code -> not much of Django left

Better Reasons not depending on DJANGO SETTINGS MODULE (might be necessary) if you need to be able to tear down the framework without restarting Python [reload] Data structure too complex for the Django ORM (might happen) You re building on non-django code

and now to something completely different Lamson dispatches based on regular expressions to mail handlers All these templates engines looking like Django (Tornado, Liquid, all these PHP clones)

Thanks Slides will be on http://lucumr.poco.org/