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

PyConZA 2013: "Enterprise Python" by Travis Pawley

Pycon ZA
October 03, 2013

PyConZA 2013: "Enterprise Python" by Travis Pawley

A quote from a fellow Python coder... "Coding in Python is like writing poetry"

My talk will be about how to bring python into the corporate / enterprise world. With over 10 years of Python and Django experience, I wish to share my tribulations and exaltations in how I managed to incorporate Python and Django into the companies I've worked for, deploying systems all over the world.

Some of the high level topics:

- How to get buy in from your executive management team
- Lack of Python developers, J2EE, PHP and other resource pools
- Integrating with existing legacy databases
- System integration, and interfaces best practice
- SQL vs No SQL
- Horizontal scaling and cloud computing

Some of the technologies I'll be discussing:

- buildout and virtualenv: Dependency Management
- django: Web Development Framework
- south: Database schema management and migration
- nose: Testing
- fabric: Deployment
- sphinx: Documentation (ReadySET)
- celery: Enterprise Integration Patterns
- rest-framework / piston: Web API
- twitter-bootstrap: HTML5, CSS3, JavaScript Development Framework
- responsive-themes: Supporting mobile devices

This talk is about using best practices, awesome libraries and the strength of existing systems and developers to rapidly deploy stable production systems into your company.

Pycon ZA

October 03, 2013
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. Python >>> import __hello__ Hello world... >>> from __future__ import

    braces File "<stdin>", line 1 SyntaxError: not a chance Monday 04 November 13
  2. Python >>> import this The Zen of Python, by Tim

    Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! Monday 04 November 13
  3. Enterprise • Standards (aka Red Tape) • Support (SLA’s) •

    Language toolkits • Java, Oracle. • Top down Monday 04 November 13
  4. Challenges • Python not a real language • Open source,

    no support • Doesn’t scale • Not fast enough • Hard to find Python developers Monday 04 November 13
  5. Development vs. Operations java.lang.NullPointerException at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:705) at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:670) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:329)

    at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4045) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4351) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:566) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Monday 04 November 13
  6. Example - Wine Farm • Have existing corporate website •

    Consulting company more interested in consuming product than supporting site • Internally take over and integrate Monday 04 November 13
  7. New Project - buildout bootstrap.py buildout.cfg fabfile.py etc/ src/ media/

    docs/ static/ templates/ bin/ develop-eggs/ eggs/ parts/ downloads/ Monday 04 November 13
  8. Forms - django-crispy-forms settings.py: INSTALLED_APPS = ( ... ‘crispy_forms’, ...

    ) template.html: {% load crispy_forms_tags %} {{ my_form|crispy }} {% crispy my_form %} Monday 04 November 13
  9. Schema Migration - south bin/django schemamigration --empty app_name initial bin/django

    schemamigration --initial app_name initial bin/django schemamigration --auto app_name bin/django migrate Monday 04 November 13
  10. Testing - django-nose INSTALLED_APPS = ( ... 'django_nose', ... )

    TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' --with-fixture-bundling Monday 04 November 13
  11. Mocking - mock from mock import Mock from pycon.internal.interfaces.sap import

    SapClient SapClient.connect = Mock() SapClient._call = Mock(return_value=True) SapClient.close = Mock() Monday 04 November 13
  12. Deployment - fabric from fabric.api import env, local, settings, abort,

    run, cd env.hosts = ['myserver1', 'myserver2'] ROOT = '/var/www/pyconza/' def test(): with cd(ROOT): local('bin/django test') def deploy(): with cd(ROOT): run('git pull') run('bin/buildout -vN') run('bin/django migrate') Monday 04 November 13
  13. Django - MongoDB • Clustering and Sharding • Great model

    support • Behind Django release • Loose your DBA’s Monday 04 November 13
  14. Cloud - libcloud • http://libcloud.apache.org/ • Amacon EC2, Rackspace Cloud,

    Google Compute Engine, vCloud, CloudStack, OpenStack Monday 04 November 13
  15. Mentions • scipy, numpy and pandas • requests • django-spurl

    • django-polymorphic • python-dateutil • suds • unipath Monday 04 November 13