SlideShare a Scribd company logo
Pinax Long Tutorial PyCon 2010
Introduction ~10 minutes
Who are we? - James Tauber Pinax Founder CEO of Eldarion http://jtauber.com
Who are we? - Daniel Greenfeld Pinax Core Developer Software Engineer for NASA's Science Mission Directorate Author/Instructor for Holden Web, LLC (holdenweb.com) Developer for Eldarion http://pydanny.com
Tutorial Prerequisites Basic understanding of Python Basic understanding of Django Laptop Python 2.5.x or 2.6.x
History of Pinax 2008: James Tauber decides to stop repeating himself 0.5 — First official release 2009: First full year of Pinax 0.7 — Groups, Static Media, Move to pip and virtualenv, Section 508 2010: Today 0.9 — Next great thing
Philosophy of Pinax By integrating numerous reusable Django apps to take care of the things that many sites have in common, it lets you focus on what makes your site different. In other words... D on't  R epeat  Y ourself
What will we be doing? Installing Pinax Reviewing the core underlying layer Changing the look and feel Various Pinax tricks Building on what Python and Django gives us Deployment Community
Pinax Installation ~10 minutes
Where to get Pinax http://pinaxproject.com/download/ USB key with bundle
virtualenv Ian Bicking Isolates all Pinax components from your global environment virtual environments is used for dependency control You can use multiple virtualenv/pinax-env http://pypi.python.org/pypi/virtualenv
pip Ian Bicking pip is a replacement for easy_install All packages are downloaded before installation. Partially-completed installation doesn't occur as a result. Supports requirement files for consistently creating environments of many packages. http://pypi.python.org/pypi/pip
Core Underlying Components ~10 minutes
Core: Accounts Avatar Email Addresses Language OpenID Password Management Signup Timezone
Sign Up Options Closed Sign Up Private Beta Optional email confirmation
Core: Groups Groups in Pinax are containers with user membership and content. They are a base on which to write your own app and plug in whatever content apps you need. Examples: Tribes (Wiki, Photos) Projects (Tasks, Wiki) Guilds (Events)
Core: Static Media Handling css, images, javascript Project vs Pinax Theme vs App level Separation of static media from user-contributed media. build_static management command for deployment
Pinax Projects ~10 minutes
Overview of the starter projects boilerplate code scaffolding to get started more quickly already integrated apps Examples: basic_project social_project code_project company_project (NEW)
Using pinax-admin List all the currently available projects in Pinax pinax-admin clone_project -l Cloning a project pinax-admin clone_project social_project djangofans
What is in a Pinax project? apps directory media directory slightly extended manage.py requirements.txt with project dependencies required to run deploy directory for modpython, fastcgi, and wsgi. templates directory with the blocking done tests directory to help push you to test.
Pinax specific settings.py ~5 minutes
Some Pinax Settings SITE_NAME (used in some default templates) CONTACT_EMAIL (used in some default templates) PINAX_THEME (prefix for template resolution) ACCOUNT_OPEN_SIGNUP (can anyone join?) ACCOUNT_REQUIRED_EMAIL (is email address required?) ACCOUNT_EMAIL_VERIFICATION (must email be verified?) EMAIL_CONFIRMATION_DAYS (how long before expiry?) LOGIN_REDIRECT_URLNAME (first page to go after login)
Media/Static Files Settings MEDIA_URL / MEDIA_ROOT     (URL and filesystem location for files uploaded/stored by Django only) STATIC_URL / STATIC_ROOT     (URL and filesystem location for site assets such as CSS, JS and images) SERVE_MEDIA      (Used in urls.py to hook-up MEDIA_URL and STATIC_URL used for development)
local_settings.py Good place for environmental settings such as:      Databases           Debug      Media locations
Modification of core  Pinax applications ~10 minutes
Profiles Frequently extended application You always want a custom field
Modification of core Pinax applications Before you change a core application: Can you accomplish your tasks with CSS? Can you accomplish your tasks with Javascript? Can you accomplish your tasks with template changes? Can you create a new application that does the work?
But my task needs a code/database change! pinax-env/lib/python2.x/site-packages/Pinax/pinax/apps/<app> pinax-env/src/Pinax/pinax/apps/<app> Don't make changes in Pinax itself!
But my task needs a code/database change! Option 1: Use the apps directory of your project cd apps/ django-admin.py startapp profiles Option 2: Use virtualenv/pip Create a stand alone app (best done eggified) pip install -e my-app
Adding Django applications ~10 minutes
Won't conversion be hard? Remember: Pinax is just Django with an opinion pip install <django-app> (Don't forget to add it to your requirements.txt file) make changes to INSTALLED_APPS, etc in settings.py make template changes
Modification of templates ~10 minutes
Customize templates, don't change them cp -r site-packages/pinax/templates/default/profiles my-project/templates Don't edit the Pinax templates directory!
Themes in Pinax Change your look and feel by just changing settings.py!  PINAX_THEME = &quot;default&quot; But only one theme is currently shipped with Pinax PINAX_THEME = &quot;default&quot;
Changing the logo Step 1: Add your image to <my-project>/media Step 2: In <my-project>/templates/site_base.html in the logo_link_image block change the name of the logo image to match your own. (but really you should be making more style changes than just the logo)
Handy Pinax template blocks head_title extra_head extra_body Loads after main body. Good for custom Javascript      footer
Changing the look and feel ~10 minutes
base.html versus site_base.html If you are writing a theme to be used across multiple sites, you  should modify base.html, not site_base.html. If you want to keep a particular theme but modify content for a  specific site, you should modify site_base.html.
Adding and removing tabs In site_base.html add a new li in the right_tabs block. Make sure that li has and id specific to that to that tab, e.g. tab_myapp Create a myapps/base.html template that all pages under that tab will extend. Make sure it defines a block body_class with contentmyapp edit the CSS file (site_tabs.css if it exists) and at the appropriate points add the selectors: body.myapp #tab_myapp body.myapp #tab_myapp a see http://pinaxproject.com/docs/dev/tabs.html for more information
Adding CSS In templates/site_base.html {% block extra_head_base %}:      <link rel=&quot;stylesheet&quot; href=&quot;{{ MEDIA_URL }}custom.css&quot; /> mkdir site_media mkdir site_media/media touch custom.css body {      background-color: #000; }
Changing Avatar defaults ~10 minutes
django-avatar by default uses Gravatar Pros: Gravatars follow a user's account name across the Internet Means users get a default avatar anywhere Cons: You might not want the default Gravatar avatar image You might not want to lock user avatars into a single service
Changing the default Gravatar logo In settings.py AVATAR_DEFAULT_URL =  STATIC_URL + &quot;<our_custom_avatar.jpg>&quot; AVATAR_GRAVATAR_BACKUP = False
django-groups ~10 minutes
What are groups? Groups in are containers with user  membership and content. Example: A project with tasks and wiki A guild with a forum and events
What does django-groups give you? Base model on which to build your group app A way to do all your URL routing so you get  to the right content objects for the group. Nested group support (group apps can be  content object apps at the same time)
Creating a group app Adding content objects is simple:      from groups.bridge import ContentBridge      bridge = ContentBridge(Project)      urlpatterns = patterns(&quot;&quot;, ...) # URLs for the group views      urlpatterns += bridge.include_urls(&quot;topics.urls&quot;, r&quot;^project/(?P<project_slug>[-\w]+)/topics/&quot;) Group model interface is simple: member_queryset (needed if member m2m is named other than members) user_is_member get_url_kwargs
Creating content object apps Most bits must be aware of group association. Views, forms, model and template context. By 0.9 most all major apps will support group protocol for content apps. Apps don't need to depend on django-groups Protocol bits of note ContentBridge get_group reverse Group model instance content_objects(Model, [ join=[...] ]) Template context {% extends group_base|default:&quot;site_base.html&quot; %}
Looking at django-groups pinax-admin clone_project sample_group_project sgp cd sgp python manage.py syncdb python manage.py runserver
django-uni-form ~10 minutes
What is Section 508? Rules for making technology theoretically accessible by individuals with disability. Easy to implement if you know how. Unfortunately doesn't actually force software to be accessible to the disabled. Enforceable across all government agencies or organizations accepting money from government agencies.
Why do we care? US Government work requires it.  Disability software is said to be a $170 billion a year industry. Open source tends to support accessibility/usability well. Its the right thing to do!
Django forms rock!
Tables are for tabular data
In Section 508, some tabular forms are allowed
Out of the box pretty Django forms are tabular
Django Uni-Form =  Django forms docs + template tag + Uni-Form css/js forms library
Basic Usage
 
Advanced Django Uni-Form ~10 minutes
Making form generation easier {% load uni_form_tags %} {% with form.helper as helper %} {% uni_form form helper %} {% endwith %}
Adding action handlers {% load uni_form_tags %} {% with form.helper as helper %} {% uni_form form helper %} {% endwith %}
Media Handling ~10 minutes
Static Files css, images, javascript Separation of static media from user-contributed media. build_static management command for deployment STATIC_URL context variable SERVE_MEDIA for development
Static media is good Caching Security Separating servers
build_static tool python manage.py help build_static Copy static media files from apps and other locations in a single location. --dry-run (don't copy but show what will be done) --link (create symlinks rather than copy) Project vs Pinax Theme vs App level
STATIC_URL TEMPLATE_CONTEXT_PROCESSORS = [      &quot;staticfiles.context_processors.static_url&quot;, ] (be sure to use RequestContext) <link href=&quot;{{ STATIC_URL }}css/polls.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; />
STATICFILES_DIRS Defines resolution order for static media handling      STATICFILES_DIRS = [          os.path.join(PROJECT_ROOT, &quot;media&quot;),          os.path.join(PINAX_ROOT, &quot;media&quot;, PINAX_THEME),      ]
Serving Static Files During Development from django.conf import settings if settings.SERVE_MEDIA:       urlpatterns += patterns(&quot;&quot;,               (r&quot;&quot;, include(&quot;staticfiles.urls&quot;)),      )
JavaScript, jQuery and Pinax ~5 minutes
Why was jQuery chosen for Pinax? Because Pinax has an opinion But you can still use YUI, Mootools, or plain old JavaScript
Best practice for JavaScript use
django-ajax-validation ~5 minutes
django-ajax-validation In urls.py:      from my_app.forms import MyAppForm      (r&quot;^validate/$&quot;, &quot;ajax_validation.views.validate&quot;, {          &quot;form_class&quot;: MyAppForm,          &quot;callback&quot;: lambda request, *args, **kwargs:                   {&quot;user&quot;: request.user}      }, &quot;myapp_form_validate&quot;),
django-ajax-validation in templates/my-app/edit.html: {% block extra_body %}      {% load jquery_validation %}      {% include_validation %}      <script type=&quot;text/javascript&quot;>          $(function(){              $('#myapp_form').validate('{% url  myapp_form_validate %}', {type: 'uni_form'});          });      </script> {% endblock %}
django-pagination ~2 minutes
django-pagination {% load pagination_tags %} ... {% autopaginate results 10 %} ...          {% paginate %} style with CSS: .pagination, .page, .page.selected, .page-prev, .page-next
Testing your Pinax application ~5 minutes
Why should you bother testing? &quot;Untested code is broken code&quot; Martin Aspelli &quot;Code without tests is broken as designed&quot; Jacob Kaplan-Moss &quot;All the cool kids are doing tests&quot; Chris Shenton &quot;If I go to another testing talk I'm going to die&quot; Daniel Greenfeld
Pinax Deployment ~10 minutes
What Pinax gives you Each project has a deploy/ directory deploy/ contains working mod_wsgi, FastCGI and mod_python deployment files. Much of Pinax has been designed to be a simple deployment with the way we've constructed settings.
Example Apache config <VirtualHost *:8001>      ServerName eldarion.com           WSGIDaemonProcess eldarion.com user=eldarion group=eldarion processes=1 threads=25 python-path=/home/eldarion/virtualenvs/eldarion_project/lib/python2.5/site-packages      WSGIProcessGroup eldarion.com           WSGIScriptAlias / /home/eldarion/webapps/eldarion.com/eldarion_project/deploy/pinax.wsgi      <Directory /home/eldarion/webapps/eldarion.com/eldarion_project/deploy>          Order deny,allow          Allow from all      </Directory>           ErrorLog /var/log/apache2/eldarion.com.error.log      LogLevel warn      CustomLog /var/log/apache2/eldarion.com.access.log combined      </VirtualHost>
Things to remember when deploying Setup cron jobs for clearing mail queue and notification queue Recommended to create a maintenance.wsgi script that you can simply cp over pinax.wsgi to take the site down for deployment (don't forget to actually do this) Always remember to run build_static before claiming your deployment is complete
Community ~10 minutes
How to communicate 1. Don't be ' that guy '. 2. Be friendly. 3. Be patient. 4. Tell us your operating system and version of Python. 5. Use a pasting service for code or shell statements:      dpaste.de      code.pinaxproject.com
Finding Help Documentation:      http://pinaxproject.com/docs/0.7/      http://pinaxproject.com/docs/dev/ IRC:      #pinax Mailing List:      http://groups.google.com/group/pinax-users
Contributing back http://code.pinaxproject.com      Task tracker and wiki for the Pinax project      Search the tickets before creating a new ticket http://github.com/pinax/pinax      Fork and submit pull requests      Tests and documentation are required      Documentation must be in restructured text
Contributing back - Modular Efforts For stand-alone Django or Python efforts:      Documentation and tests are required      Make your work modular and easy to use      Put your finished work on PyPI
Q & A

More Related Content

PDF
Intro to Pinax: Kickstarting Your Django Apps
PDF
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
PPTX
Building JavaScript
PPT
Freelancer Weapons of mass productivity
PDF
State Of Opensocial
PDF
Scalable Apps with Google App Engine
PDF
Building Video Applications with YouTube APIs
PDF
Django - basics
Intro to Pinax: Kickstarting Your Django Apps
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
Building JavaScript
Freelancer Weapons of mass productivity
State Of Opensocial
Scalable Apps with Google App Engine
Building Video Applications with YouTube APIs
Django - basics

Similar to Pinax Long Tutorial Slides (20)

PPT
PPTX
M365 global developer bootcamp 2019 Intro to SPFx Version
ODP
Web Development in Django
PDF
Dev con pnp-engine-presentation
PDF
Python Django tutorial | Getting Started With Django | Web Development With D...
ODP
A winning combination: Plone as CMS and your favorite Python web framework as...
PDF
Django Article V0
PDF
Expanding XPages with Bootstrap Plugins for Ultimate Usability
PPTX
Ready, Set, Upgrade!
PPTX
UMD User's Group: DrupalCon 2011, Chicago
PDF
بررسی چارچوب جنگو
PPTX
DOCX
Company Visitor Management System Report.docx
DOC
Dreamwares Recent Projects
PDF
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
PPTX
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
PPTX
Django Girls Tutorial
PPTX
Lazy Coder Camp Edition 1
PPTX
M365 global developer bootcamp 2019 Intro to SPFx Version
Web Development in Django
Dev con pnp-engine-presentation
Python Django tutorial | Getting Started With Django | Web Development With D...
A winning combination: Plone as CMS and your favorite Python web framework as...
Django Article V0
Expanding XPages with Bootstrap Plugins for Ultimate Usability
Ready, Set, Upgrade!
UMD User's Group: DrupalCon 2011, Chicago
بررسی چارچوب جنگو
Company Visitor Management System Report.docx
Dreamwares Recent Projects
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Tech Winter Break - GDG OnCampus International Institute of Information Techn...
Django Girls Tutorial
Lazy Coder Camp Edition 1
Ad

More from Daniel Greenfeld (20)

PDF
How to Write a Popular Python Library by Accident
PDF
10 more-things-you-can-do-with-python
PDF
From NASA to Startups to Big Commerce
PDF
Thinking hard about_python
PDF
Intro to Data Visualizations
PDF
An Extreme Talk about the Zen of Python
KEY
PyCon Philippines 2012 Keynote
KEY
Round pegs and square holes
PDF
Intro to Python
KEY
Lighting talk on django-social-auth
KEY
Future of Collaboration
KEY
Advanced Django Forms Usage
KEY
The One Way
KEY
Confessions of Joe Developer
PDF
Python Worst Practices
PDF
Django Worst Practices
PDF
How to sell django panel
PPT
Testing In Django
PDF
Django Uni-Form
How to Write a Popular Python Library by Accident
10 more-things-you-can-do-with-python
From NASA to Startups to Big Commerce
Thinking hard about_python
Intro to Data Visualizations
An Extreme Talk about the Zen of Python
PyCon Philippines 2012 Keynote
Round pegs and square holes
Intro to Python
Lighting talk on django-social-auth
Future of Collaboration
Advanced Django Forms Usage
The One Way
Confessions of Joe Developer
Python Worst Practices
Django Worst Practices
How to sell django panel
Testing In Django
Django Uni-Form
Ad

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The AUB Centre for AI in Media Proposal.docx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
sap open course for s4hana steps from ECC to s4
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
“AI and Expert System Decision Support & Business Intelligence Systems”
Programs and apps: productivity, graphics, security and other tools
Diabetes mellitus diagnosis method based random forest with bat algorithm
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
MYSQL Presentation for SQL database connectivity

Pinax Long Tutorial Slides

  • 1. Pinax Long Tutorial PyCon 2010
  • 3. Who are we? - James Tauber Pinax Founder CEO of Eldarion http://jtauber.com
  • 4. Who are we? - Daniel Greenfeld Pinax Core Developer Software Engineer for NASA's Science Mission Directorate Author/Instructor for Holden Web, LLC (holdenweb.com) Developer for Eldarion http://pydanny.com
  • 5. Tutorial Prerequisites Basic understanding of Python Basic understanding of Django Laptop Python 2.5.x or 2.6.x
  • 6. History of Pinax 2008: James Tauber decides to stop repeating himself 0.5 — First official release 2009: First full year of Pinax 0.7 — Groups, Static Media, Move to pip and virtualenv, Section 508 2010: Today 0.9 — Next great thing
  • 7. Philosophy of Pinax By integrating numerous reusable Django apps to take care of the things that many sites have in common, it lets you focus on what makes your site different. In other words... D on't R epeat Y ourself
  • 8. What will we be doing? Installing Pinax Reviewing the core underlying layer Changing the look and feel Various Pinax tricks Building on what Python and Django gives us Deployment Community
  • 10. Where to get Pinax http://pinaxproject.com/download/ USB key with bundle
  • 11. virtualenv Ian Bicking Isolates all Pinax components from your global environment virtual environments is used for dependency control You can use multiple virtualenv/pinax-env http://pypi.python.org/pypi/virtualenv
  • 12. pip Ian Bicking pip is a replacement for easy_install All packages are downloaded before installation. Partially-completed installation doesn't occur as a result. Supports requirement files for consistently creating environments of many packages. http://pypi.python.org/pypi/pip
  • 14. Core: Accounts Avatar Email Addresses Language OpenID Password Management Signup Timezone
  • 15. Sign Up Options Closed Sign Up Private Beta Optional email confirmation
  • 16. Core: Groups Groups in Pinax are containers with user membership and content. They are a base on which to write your own app and plug in whatever content apps you need. Examples: Tribes (Wiki, Photos) Projects (Tasks, Wiki) Guilds (Events)
  • 17. Core: Static Media Handling css, images, javascript Project vs Pinax Theme vs App level Separation of static media from user-contributed media. build_static management command for deployment
  • 19. Overview of the starter projects boilerplate code scaffolding to get started more quickly already integrated apps Examples: basic_project social_project code_project company_project (NEW)
  • 20. Using pinax-admin List all the currently available projects in Pinax pinax-admin clone_project -l Cloning a project pinax-admin clone_project social_project djangofans
  • 21. What is in a Pinax project? apps directory media directory slightly extended manage.py requirements.txt with project dependencies required to run deploy directory for modpython, fastcgi, and wsgi. templates directory with the blocking done tests directory to help push you to test.
  • 23. Some Pinax Settings SITE_NAME (used in some default templates) CONTACT_EMAIL (used in some default templates) PINAX_THEME (prefix for template resolution) ACCOUNT_OPEN_SIGNUP (can anyone join?) ACCOUNT_REQUIRED_EMAIL (is email address required?) ACCOUNT_EMAIL_VERIFICATION (must email be verified?) EMAIL_CONFIRMATION_DAYS (how long before expiry?) LOGIN_REDIRECT_URLNAME (first page to go after login)
  • 24. Media/Static Files Settings MEDIA_URL / MEDIA_ROOT    (URL and filesystem location for files uploaded/stored by Django only) STATIC_URL / STATIC_ROOT    (URL and filesystem location for site assets such as CSS, JS and images) SERVE_MEDIA      (Used in urls.py to hook-up MEDIA_URL and STATIC_URL used for development)
  • 25. local_settings.py Good place for environmental settings such as:      Databases           Debug      Media locations
  • 26. Modification of core  Pinax applications ~10 minutes
  • 27. Profiles Frequently extended application You always want a custom field
  • 28. Modification of core Pinax applications Before you change a core application: Can you accomplish your tasks with CSS? Can you accomplish your tasks with Javascript? Can you accomplish your tasks with template changes? Can you create a new application that does the work?
  • 29. But my task needs a code/database change! pinax-env/lib/python2.x/site-packages/Pinax/pinax/apps/<app> pinax-env/src/Pinax/pinax/apps/<app> Don't make changes in Pinax itself!
  • 30. But my task needs a code/database change! Option 1: Use the apps directory of your project cd apps/ django-admin.py startapp profiles Option 2: Use virtualenv/pip Create a stand alone app (best done eggified) pip install -e my-app
  • 32. Won't conversion be hard? Remember: Pinax is just Django with an opinion pip install <django-app> (Don't forget to add it to your requirements.txt file) make changes to INSTALLED_APPS, etc in settings.py make template changes
  • 34. Customize templates, don't change them cp -r site-packages/pinax/templates/default/profiles my-project/templates Don't edit the Pinax templates directory!
  • 35. Themes in Pinax Change your look and feel by just changing settings.py!  PINAX_THEME = &quot;default&quot; But only one theme is currently shipped with Pinax PINAX_THEME = &quot;default&quot;
  • 36. Changing the logo Step 1: Add your image to <my-project>/media Step 2: In <my-project>/templates/site_base.html in the logo_link_image block change the name of the logo image to match your own. (but really you should be making more style changes than just the logo)
  • 37. Handy Pinax template blocks head_title extra_head extra_body Loads after main body. Good for custom Javascript      footer
  • 38. Changing the look and feel ~10 minutes
  • 39. base.html versus site_base.html If you are writing a theme to be used across multiple sites, you  should modify base.html, not site_base.html. If you want to keep a particular theme but modify content for a  specific site, you should modify site_base.html.
  • 40. Adding and removing tabs In site_base.html add a new li in the right_tabs block. Make sure that li has and id specific to that to that tab, e.g. tab_myapp Create a myapps/base.html template that all pages under that tab will extend. Make sure it defines a block body_class with contentmyapp edit the CSS file (site_tabs.css if it exists) and at the appropriate points add the selectors: body.myapp #tab_myapp body.myapp #tab_myapp a see http://pinaxproject.com/docs/dev/tabs.html for more information
  • 41. Adding CSS In templates/site_base.html {% block extra_head_base %}:      <link rel=&quot;stylesheet&quot; href=&quot;{{ MEDIA_URL }}custom.css&quot; /> mkdir site_media mkdir site_media/media touch custom.css body {      background-color: #000; }
  • 43. django-avatar by default uses Gravatar Pros: Gravatars follow a user's account name across the Internet Means users get a default avatar anywhere Cons: You might not want the default Gravatar avatar image You might not want to lock user avatars into a single service
  • 44. Changing the default Gravatar logo In settings.py AVATAR_DEFAULT_URL =  STATIC_URL + &quot;<our_custom_avatar.jpg>&quot; AVATAR_GRAVATAR_BACKUP = False
  • 46. What are groups? Groups in are containers with user  membership and content. Example: A project with tasks and wiki A guild with a forum and events
  • 47. What does django-groups give you? Base model on which to build your group app A way to do all your URL routing so you get to the right content objects for the group. Nested group support (group apps can be content object apps at the same time)
  • 48. Creating a group app Adding content objects is simple:      from groups.bridge import ContentBridge      bridge = ContentBridge(Project)      urlpatterns = patterns(&quot;&quot;, ...) # URLs for the group views      urlpatterns += bridge.include_urls(&quot;topics.urls&quot;, r&quot;^project/(?P<project_slug>[-\w]+)/topics/&quot;) Group model interface is simple: member_queryset (needed if member m2m is named other than members) user_is_member get_url_kwargs
  • 49. Creating content object apps Most bits must be aware of group association. Views, forms, model and template context. By 0.9 most all major apps will support group protocol for content apps. Apps don't need to depend on django-groups Protocol bits of note ContentBridge get_group reverse Group model instance content_objects(Model, [ join=[...] ]) Template context {% extends group_base|default:&quot;site_base.html&quot; %}
  • 50. Looking at django-groups pinax-admin clone_project sample_group_project sgp cd sgp python manage.py syncdb python manage.py runserver
  • 52. What is Section 508? Rules for making technology theoretically accessible by individuals with disability. Easy to implement if you know how. Unfortunately doesn't actually force software to be accessible to the disabled. Enforceable across all government agencies or organizations accepting money from government agencies.
  • 53. Why do we care? US Government work requires it. Disability software is said to be a $170 billion a year industry. Open source tends to support accessibility/usability well. Its the right thing to do!
  • 55. Tables are for tabular data
  • 56. In Section 508, some tabular forms are allowed
  • 57. Out of the box pretty Django forms are tabular
  • 58. Django Uni-Form = Django forms docs + template tag + Uni-Form css/js forms library
  • 60.  
  • 62. Making form generation easier {% load uni_form_tags %} {% with form.helper as helper %} {% uni_form form helper %} {% endwith %}
  • 63. Adding action handlers {% load uni_form_tags %} {% with form.helper as helper %} {% uni_form form helper %} {% endwith %}
  • 65. Static Files css, images, javascript Separation of static media from user-contributed media. build_static management command for deployment STATIC_URL context variable SERVE_MEDIA for development
  • 66. Static media is good Caching Security Separating servers
  • 67. build_static tool python manage.py help build_static Copy static media files from apps and other locations in a single location. --dry-run (don't copy but show what will be done) --link (create symlinks rather than copy) Project vs Pinax Theme vs App level
  • 68. STATIC_URL TEMPLATE_CONTEXT_PROCESSORS = [      &quot;staticfiles.context_processors.static_url&quot;, ] (be sure to use RequestContext) <link href=&quot;{{ STATIC_URL }}css/polls.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; />
  • 69. STATICFILES_DIRS Defines resolution order for static media handling      STATICFILES_DIRS = [          os.path.join(PROJECT_ROOT, &quot;media&quot;),          os.path.join(PINAX_ROOT, &quot;media&quot;, PINAX_THEME),      ]
  • 70. Serving Static Files During Development from django.conf import settings if settings.SERVE_MEDIA:       urlpatterns += patterns(&quot;&quot;,               (r&quot;&quot;, include(&quot;staticfiles.urls&quot;)),      )
  • 71. JavaScript, jQuery and Pinax ~5 minutes
  • 72. Why was jQuery chosen for Pinax? Because Pinax has an opinion But you can still use YUI, Mootools, or plain old JavaScript
  • 73. Best practice for JavaScript use
  • 75. django-ajax-validation In urls.py:      from my_app.forms import MyAppForm      (r&quot;^validate/$&quot;, &quot;ajax_validation.views.validate&quot;, {          &quot;form_class&quot;: MyAppForm,          &quot;callback&quot;: lambda request, *args, **kwargs:                   {&quot;user&quot;: request.user}      }, &quot;myapp_form_validate&quot;),
  • 76. django-ajax-validation in templates/my-app/edit.html: {% block extra_body %}      {% load jquery_validation %}      {% include_validation %}      <script type=&quot;text/javascript&quot;>          $(function(){              $('#myapp_form').validate('{% url  myapp_form_validate %}', {type: 'uni_form'});          });      </script> {% endblock %}
  • 78. django-pagination {% load pagination_tags %} ... {% autopaginate results 10 %} ...          {% paginate %} style with CSS: .pagination, .page, .page.selected, .page-prev, .page-next
  • 79. Testing your Pinax application ~5 minutes
  • 80. Why should you bother testing? &quot;Untested code is broken code&quot; Martin Aspelli &quot;Code without tests is broken as designed&quot; Jacob Kaplan-Moss &quot;All the cool kids are doing tests&quot; Chris Shenton &quot;If I go to another testing talk I'm going to die&quot; Daniel Greenfeld
  • 82. What Pinax gives you Each project has a deploy/ directory deploy/ contains working mod_wsgi, FastCGI and mod_python deployment files. Much of Pinax has been designed to be a simple deployment with the way we've constructed settings.
  • 83. Example Apache config <VirtualHost *:8001>      ServerName eldarion.com           WSGIDaemonProcess eldarion.com user=eldarion group=eldarion processes=1 threads=25 python-path=/home/eldarion/virtualenvs/eldarion_project/lib/python2.5/site-packages      WSGIProcessGroup eldarion.com           WSGIScriptAlias / /home/eldarion/webapps/eldarion.com/eldarion_project/deploy/pinax.wsgi      <Directory /home/eldarion/webapps/eldarion.com/eldarion_project/deploy>          Order deny,allow          Allow from all      </Directory>           ErrorLog /var/log/apache2/eldarion.com.error.log      LogLevel warn      CustomLog /var/log/apache2/eldarion.com.access.log combined      </VirtualHost>
  • 84. Things to remember when deploying Setup cron jobs for clearing mail queue and notification queue Recommended to create a maintenance.wsgi script that you can simply cp over pinax.wsgi to take the site down for deployment (don't forget to actually do this) Always remember to run build_static before claiming your deployment is complete
  • 86. How to communicate 1. Don't be ' that guy '. 2. Be friendly. 3. Be patient. 4. Tell us your operating system and version of Python. 5. Use a pasting service for code or shell statements:      dpaste.de      code.pinaxproject.com
  • 87. Finding Help Documentation:      http://pinaxproject.com/docs/0.7/      http://pinaxproject.com/docs/dev/ IRC:      #pinax Mailing List:      http://groups.google.com/group/pinax-users
  • 88. Contributing back http://code.pinaxproject.com      Task tracker and wiki for the Pinax project      Search the tickets before creating a new ticket http://github.com/pinax/pinax      Fork and submit pull requests      Tests and documentation are required      Documentation must be in restructured text
  • 89. Contributing back - Modular Efforts For stand-alone Django or Python efforts:      Documentation and tests are required      Make your work modular and easy to use      Put your finished work on PyPI
  • 90. Q & A

Editor's Notes

  • #8: Mention:      LEGO      scaffolding
  • #12: Mention virtualenvwrapper by Doug Hellman.
  • #13: pip is an important part of Pinax for installing Python packages. We contribute back everything we do with it.
  • #16: At some point we probably want to review the account-relevant settings
  • #17: Point out that pinax groups are a base on which you write your own group app and plug in whatever content apps you need.
  • #18: There&apos;s more to static files than this. Mention the three levels of project, pinax theme and app Point out the analogies with template resolution Pluggable storage backend (http://pypi.python.org/pypi/django-staticfiles/#staticfiles-storage) allows to &amp;quot;build&amp;quot; static files to non filesystem storages, e.g. S3
  • #22: A proposal was accepted to fix how we handle project-level requirements. we will be working on it during PyCon
  • #24: MAILER_PAUSE_SEND is a boolean value that is checked whether or not the management command should even be ran (from the cron)
  • #47: JT: [REPEAT] I would say that groups are &amp;quot;containers with user membership and content&amp;quot; (i.e. can&apos;t skip the user membership aspect of it). JT: [REPEAT] we should point out that pinax groups are a base on which you write your own group app and plug in whatever content apps you need. JT: the key thing is that a content app that is group aware doesn&apos;t need to know about the specifics of the site developer&apos;s group app
  • #51: JT: we need to explain with examples of urls.py and models.py and views.py I think how this all works DG: I&apos;ll get a set of simple working examples out before presentation that people can thumb through. Or maybe add to sample_group_project.
  • #68: JL: maby other storage backends could be shown here, e.g. S3 or cloudfiles also see resolve_static management command
  • #74: Technically you can just say $(function() {...});
  • #84: BR: port number is set to 8001 for a common situation where Apache is proxied by a front-end webserver (recommended)