Use of django at jolt online v3

Embed Size (px)

DESCRIPTION

Talk on Python Ireland 14th April 2010

Citation preview

  • 1. THE USE OF AT J AIMEB UELTA [email_address]

2. Presentaci'on de Jolt Online 3. Overview de retail campaign 4. 5. ATYPICAL 6.

    • csv_file = StringIO()
  • 7. output_file = csv.writer(csv_file,

8. dialect=csv.excel) 9. output_file.writerow([ 'Time UTC' , 10. datetime.datetime.utcnow()]) 11. output_file.writerow([ 'Column1' , 'Column2' ])output_file.writerows( 12. (value,'{0}%' .format(value/total *100 )) 13. forvalueindata) 14. returnHttpResponse(csv_file.getvalue(), 'text/csv' ) 15.

    • fromdrawing_charimportLineChart
  • 16. # Instance Do fancy stuff

17. d = LineChart(WIDTH, HEIGTH) 18. # Data is just a list of values 19. d.char.data = ( 1.2 ,2.3 ,4.5 ) 20. # X axis labels 21. d.chart.categoryAxis.categoryNames=( 't1' , 't2' ,'t3' ) 22. binary = d.asString( 'png' ) 23. returnHttpResponse(binary, 'image/png' ) 24. C/C++ 25. DATABASE WORK 26. FIXTURES 27.

  • # Setup environment for Django ORM fromdjango.confimportsettings importos fromcodecsimportignore_errors if 'DJANGO_SETTINGS_MODULE' not inos.environ: os.environ[ 'DJANGO_SETTINGS_MODULE '] ='settings'

28. CALCULATE DATA 29. MAINTENANCE AND CLEANING 30. IMPORT DATA 31. ORM PROBLEMS 32. GENERATE MILLIONS OF PROMOCODES TIME > 3 HOURS 33. CREATE & LOAD SQLSCRIPT TIME < 3 MIN 34. OTHER TOOLS 35. PRODUCTION STAGING Fabric virtenv virtenv 36. VIRTUAL ENVIRONMENT 37. FABRIC

  • defdeploy(): ''' Update the project from the GIT repository to stable code. ''' withcd(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' )

38. FABRIC

  • $ 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:* branchmaster -> 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 .

39. COORDINATION WITH git 40. gitVSSubVersion Frequent commits Branching and merging Complex 41. git

  • Version control

42. Cooperation with other developers and help deploying in production 43. 44. Questions? QUESTIONS?