Compiled Websites with Plone, Django, Xapian and SSI

1,856 views

Published on

Slides from RuPy 2009 talk "Compiled Websites with Plone, Django, Xapian and SSI" by Łukasz Langa and Wojciech Lichota.

Published in: Technology
  • Video from presentation:

    <br /><object type="application/x-shockwave-flash" data="http://blip.tv/play/AYG5kywC" width="350" height="288"><param name="movie" value="http://blip.tv/play/AYG5kywC"></param><embed src="http://blip.tv/play/AYG5kywC" width="350" height="288" type="application/x-shockwave-flash"></embed></object>
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Compiled Websites with Plone, Django, Xapian and SSI

  1. 1. Compiled Websites with Plone, Django and SSI Łukasz Langa" " Wojciech Lichota"
  2. 2. Agenda   Reasoning   Plone and Static Deployment   Django and SSI   Search (Xapian)
  3. 3.   Security solutions requiring 100% guarantee that the content cannot be edited from the Web Reasoning   Performance The Problem dynamic Websites are resource hungry   Quality Assurance the ability to review complete content and functionality before every deployment
  4. 4.   Security front-end/back-end division two-level authentication Reasoning   Performance throwing hardware at the Existing Approaches problem caching   Quality Assurance dedicated workflow environments test instances
  5. 5. Reasoning The Solution Website compilation
  6. 6.   Convert all Website resources to static files   HTML   CSS   JS The Solution   attachments Static Deployment   media   Deploy the HTML on a traditional Web server ✓  orders of magnitude better performance ✓  incredibly simple scalability ✓  server-agnostic quality assurance
  7. 7.   Examples:   HTTrack     wget  -­‐-­‐mirror   Static Deployment ✓  out-of-the-box solution with external tools ✗  weak control of output ✗  slow
  8. 8.   Solutions for Plone:   enpraxis.staticsite     stxnext.staticdeployment   Static ✓  much faster than external Deployment solutions with internal tools ✓  fully configurable ✓  easy to customize ✗  needs integration with website
  9. 9.   Open-Source (ZPL)   two parts of configuration Static   basic: for content editors   advanced: for Deployment administrators stxnext.staticdeployment     incremental   content transformations   pluggable   integration with Xapian
  10. 10. stxnext.staticdeployment  
  11. 11. stxnext.staticdeployment  
  12. 12.   User profiles   Commenting Static   User communication Deployment   Search ...too static! We need something more sophisticated!
  13. 13.   Plone + Static Deployment The Solution   Django for:   User profiles   Commenting   User communication   Xapian for search Compiled Website
  14. 14. How to glue components together? The Solution   client-side approach: JavaScript ✓  simple implementation ✗  many requests ✗  page flickering   server-side approach: Apache SSI ✓  single request ✓  transparent to the user Compiled Website ✗  skin customization
  15. 15.   HTML preprocessor provided by Apache httpd at least since version 1.3   Processing controlled by The Glue SGML comments   Basically enables: Apache mod_include (SSI)   conditional text   inclusion of other files   inclusion of programs   printing/setting environment variables
  16. 16.   A basic SSI element: Apache mod_include <!-­‐-­‐#element  attribute=value  attribute=value  ...  -­‐-­‐>     no whitespace   Typical elements:   #include     #echo     #exec     #set     #if  /  #elif  /  #else  /  #endif  
  17. 17.   Enabling SSI in the server configuration: Apache mod_include ...   LoadModule  include_module  modules/mod_include.so   ...   AddType  text/html  .html   AddOutputFilter  INCLUDES  .html   ...   Options  +Includes     Examples of basic directives:   current date on the server <!-­‐-­‐#echo  var="DATE_LOCAL"  -­‐-­‐>   file modification date Last  modified:  <!-­‐-­‐#flastmod  file="index.html"  -­‐-­‐>   inclusion of results from a dynamic application <!-­‐-­‐#include  virtual="/app-­‐comments/thread/3/"  -­‐-­‐>     executing local commands <!-­‐-­‐#exec  cmd="uptime"  -­‐-­‐>  
  18. 18.   Inclusion of results from a dynamic application <!-­‐-­‐#include  virtual="/app-­‐comments/thread/3/"  -­‐-­‐>   Apache mod_include   How to specify an external application to be available from /app-­‐comments  ? RewriteEngine  on   RewriteRule  ^/app-­‐comments/(.*)$  http://localhost:8686/$1  [L,P]     What if the external application is not available?   Apache includes the following message by default: [an  error  occurred  while  processing  this  directive]     This can be customized in server configuration by: SSIErrorMsg  "<!-­‐-­‐  Error  -­‐-­‐>”     The default message can be overriden in HTML by: <!-­‐-­‐#config  errmsg=”Custom  message"  -­‐-­‐>  
  19. 19.   context-specific arguments need to be GET params   by default Django uses URL parts Gotchas   redirect after POST requests Gluing Django with SSI   POST requests cannot render anything   form validation requires additional plumbing   Website templating in two places   Plone skin   Django templates
  20. 20.   Apache is slow... Gotchas Apache httpd
  21. 21.   Apache is slow... NOT!   mpm_prefork  is evil   use mpm_worker     any experience with mpm_event? Gotchas   Advantages of Apache: Apache httpd   largest install base   maturity measured in years   the best WSGI module available (mod_wsgi)
  22. 22.    python-­‐xapian  binding   Ranked search What about   Suggests spelling corrections search?   no Polish stemming Xapian with SSI
  23. 23. Compiled Websites Starring Łukasz Langa" lukasz.langa.pl lukasz@langa.pl @llanga "
  24. 24. Compiled Websites Starring Wojciech Lichota www.lichota.pl wojciech@lichota.pl @wlichota "
  25. 25. Compiled Websites Guest Starring Django Pony www.djangopony.com @djangopony "
  26. 26. Questions?

×