Professional Documents
Culture Documents
PyCon 2010
Introduction
~10 minutes
Who are we? - James Tauber
Pinax Founder
CEO of Eldarion
http://jtauber.com
Who are we? - Daniel Greenfeld
http://pydanny.com
Tutorial Prerequisites
• Laptop
2010: Today
0.9 — Next great thing
Philosophy of Pinax
In other words...
Installing Pinax
Deployment
Community
Pinax Installation
~10 minutes
Where to get Pinax
• http://pinaxproject.com/download/
• Ian Bicking
• http://pypi.python.org/pypi/virtualenv
pip
• Ian Bicking
• 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
Examples:
Tribes (Wiki, Photos)
Projects (Tasks, Wiki)
Guilds (Events)
Core: Static Media Handling
css, images, javascript
boilerplate code
pinax-admin clone_project -l
Cloning a project
• media directory
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
Databases
Debug
Media locations
Modification of core
Pinax applications
~10 minutes
Profiles
pinax-env/src/Pinax/pinax/apps/<app>
But my task needs a code/database change!
cd apps/
django-admin.py startapp profiles
cp -r site-packages/pinax/templates/default/profiles my-project/templates
PINAX_THEME = "default"
PINAX_THEME = "default"
Changing the logo
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
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:
Cons:
You might not want to lock user avatars into a single service
Changing the default Gravatar logo
In settings.py
~10 minutes
What are groups?
Example:
~10 minutes
What is Section 508?
~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 %}
{% endwith %}
Media Handling
~10 minutes
Static Files
Caching
Security
Separating servers
build_static tool
TEMPLATE_CONTEXT_PROCESSORS = [
"staticfiles.context_processors.static_url",
]
STATICFILES_DIRS = [
os.path.join(PROJECT_ROOT, "media"),
os.path.join(PINAX_ROOT, "media", PINAX_THEME),
]
Serving Static Files During
Development
from django.conf import settings
if settings.SERVE_MEDIA:
urlpatterns += patterns("",
(r"", include("staticfiles.urls")),
)
JavaScript, jQuery and Pinax
~5 minutes
Why was jQuery chosen for Pinax?
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:
(r"^validate/$", "ajax_validation.views.validate", {
"form_class": MyAppForm,
"callback": lambda request, *args, **kwargs:
{"user": request.user}
}, "myapp_form_validate"),
django-ajax-validation
in templates/my-app/edit.html:
{% block extra_body %}
{% load jquery_validation %}
{% include_validation %}
<script type="text/javascript">
$(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 %}
~5 minutes
Why should you bother testing?
~10 minutes
What Pinax gives you
<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
~10 minutes
How to communicate
2. Be friendly.
3. Be patient.
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
http://github.com/pinax/pinax