Successfully reported this slideshow.

Use of django at jolt online v3

1,104 views

Published on

Talk on Python Ireland 14th April 2010

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Use of django at jolt online v3

  1. 1. THE USE OF AT J AIME B UELTA [email_address]
  2. 2. Presentaci'on de Jolt Online
  3. 3. Overview de retail campaign
  4. 5. ATYPICAL
  5. 6. <ul><ul><li>csv_file = StringIO()
  6. 7. output_file = csv.writer(csv_file,
  7. 8. dialect=csv.excel)
  8. 9. output_file.writerow([ 'Time UTC' ,
  9. 10. datetime.datetime.utcnow()])
  10. 11. output_file.writerow([ 'Column1' , 'Column2' ]) output_file.writerows(
  11. 12. (value, '{0}%' .format(value/total * 100 ))
  12. 13. for value in data)
  13. 14. return HttpResponse(csv_file.getvalue(), 'text/csv' ) </li></ul></ul>
  14. 15. <ul><ul><li>from drawing_char import LineChart
  15. 16. # Instance Do fancy stuff
  16. 17. d = LineChart(WIDTH, HEIGTH)
  17. 18. # Data is just a list of values
  18. 19. d.char.data = ( 1.2 , 2.3 , 4.5 )
  19. 20. # X axis labels
  20. 21. d.chart.categoryAxis.categoryNames=( 't1' , 't2' , 't3' )
  21. 22. binary = d.asString( 'png' )
  22. 23. return HttpResponse(binary, 'image/png' ) </li></ul></ul>
  23. 24. C/C++
  24. 25. DATABASE WORK
  25. 26. FIXTURES
  26. 27. <ul># Setup environment for Django ORM from django.conf import settings import os from codecs import ignore_errors if 'DJANGO_SETTINGS_MODULE' not in os.environ: os.environ[ 'DJANGO_SETTINGS_MODULE '] = 'settings' </ul>
  27. 28. CALCULATE DATA
  28. 29. MAINTENANCE AND CLEANING
  29. 30. IMPORT DATA
  30. 31. ORM PROBLEMS
  31. 32. GENERATE MILLIONS OF PROMOCODES TIME > 3 HOURS
  32. 33. CREATE & LOAD SQL SCRIPT TIME < 3 MIN
  33. 34. OTHER TOOLS
  34. 35. PRODUCTION STAGING Fabric virtenv virtenv
  35. 36. VIRTUAL ENVIRONMENT
  36. 37. FABRIC <ul>def deploy(): ''' Update the project from the GIT repository to stable code. ''' with cd(git_dir): run( 'git reset --hard HEAD^' ) run( 'git pull origin master' ) run( 'git checkout master' ) _print_branch( 'master' , env.role) sudo( '/etc/init.d/cherokee restart' ) </ul>
  37. 38. FABRIC <ul>$ fab -i key.pem production deploy [prod.com:22] run: git reset --hard HEAD [prod.com:22] out: HEAD is now at 15e6333 Merge branch 'master' of ssh://gitserver/services [prod.com:22] run: git pull origin master [prod.com:22] err: From origin:/services [prod.com:22] err: * branch master -> FETCH_HEAD [prod.com:22] out: Already up-to-date. [prod.com:22] run: git checkout master [prod.com:22] err: Already on 'master' ################################################# ## Using branch MASTER on PRODUCTION server ## ################################################# [prod.com:22] sudo: /etc/init.d/cherokee restart [prod.com:22] out: Stopping web server: cherokee . [prod.com:22] out: Starting web server: cherokee . </ul>
  38. 39. COORDINATION WITH git
  39. 40. git VS SubVersion Frequent commits Branching and merging Complex
  40. 41. git <ul><li>Version control
  41. 42. Cooperation with other developers and help deploying in production </li></ul>
  42. 44. Questions? QUESTIONS?

×