The slides printed for attendees of the Pycon 2010 Long Pinax Tutorial. James Tauber was the co-author and deserves tons of credit for his work. So does Brian Rosner and the rest of the Pinax team.
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.
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
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
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
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)
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 = "default" But only one theme is currently shipped with Pinax PINAX_THEME = "default"
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)
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 + "<our_custom_avatar.jpg>" AVATAR_GRAVATAR_BACKUP = False
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
80. Why should you bother testing? "Untested code is broken code" Martin Aspelli "Code without tests is broken as designed" Jacob Kaplan-Moss "All the cool kids are doing tests" Chris Shenton "If I go to another testing talk I'm going to die" Daniel Greenfeld
pip is an important part of Pinax for installing Python packages. We contribute back everything we do with it.
At some point we probably want to review the account-relevant settings
Point out that pinax groups are a base on which you write your own group app and plug in whatever content apps you need.
There'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 &quot;build&quot; static files to non filesystem storages, e.g. S3
A proposal was accepted to fix how we handle project-level requirements. we will be working on it during PyCon
MAILER_PAUSE_SEND is a boolean value that is checked whether or not the management command should even be ran (from the cron)
JT: [REPEAT] I would say that groups are &quot;containers with user membership and content&quot; (i.e. can'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't need to know about the specifics of the site developer's group app
JT: we need to explain with examples of urls.py and models.py and views.py I think how this all works DG: I'll get a set of simple working examples out before presentation that people can thumb through. Or maybe add to sample_group_project.
JL: maby other storage backends could be shown here, e.g. S3 or cloudfiles also see resolve_static management command
Technically you can just say $(function() {...});
BR: port number is set to 8001 for a common situation where Apache is proxied by a front-end webserver (recommended)