introduction to django web application framework and ...€¦ · introduction to django web...
TRANSCRIPT
Introduction to Django Web Application Framework and
Monitoring integration with I3LiveKai Schatto
Mainz
Django web application framework(Open source --- Python --- model-view-controller pattern)
• Object-relational mapping for MySQL, Oracle, PostgreSQL und SQLite
• view system for processing requests
• flexible URL configuration with reg. expr.
• Template system
• dynamic administrative interface
• Caching
• internationalization system
• authentication system
• form serialization and validation system
• etc …. http://www.djangoproject.com/
Django Database useDatabase tables (models)
class Trigger(models.Model):run = models.ForeignKey(MoniRun)trigger_type = models.ForeignKey(TriggerType)rate = models.CharField(max_length=50)rate_err = models.CharField(max_length=50)
Database access
# get all Triggers for run 114758 from Databasecurrent_run = MoniRun.objects.get(number = „114758“)for trigger in Trigger.objects.filter(run = current_run):
my_rate = trigger.ratemy_rate_err = trigger.rate_err…
MySQL Server
Raw SQL command
Python MySQLdb binding
Django ORM
Django code
Django Template System1. PageRequest for „https://live.icecube.wisc.edu/anypage/“
2. Call the python function assigned to this address
3. Collect and process necessary data and provide to template
4. Render page with integrated data
Template example<p>Dear {{ person_name }},</p><p>Thanks for placing an order from {{ company }}.
It's scheduled to ship on {{ship_date}}.</p>
<p>Here are the items you've ordered:</p>
<ul>{% for item in item_list %}<li>{{ item }}</li>{% endfor %}</ul>
{% if ordered_warranty %} <p>Your warranty information will be included in the packaging.</p> {% endif %}
Run Info
Etc.
– lxml for parsing (http://codespeak.net/lxml/)
– MySQL DB
• XML DB with lxml (Problem: corrupted XML files)
• automatic script checking for new data and saving to database
ATWD
MPE Scaler
SPE Scaler
Launches
Moni integration - Technology
All DomsBad Doms
Dead Doms
FilterSN alarms
TriggerDaily script Database
Backbone delivers bunch of xml-files
Daq-Config
Parsing XML files
• Using lxml
– Pythonic binding for the libxml2 and libxsltlibraries
– Fast!
– Easy, pythonic interface
lxml example# parsetree = lxml.etree.parse(path)# loop over all doms
for dom in tree.findall('.//' + „dom“):my_text = dom.findtext(„mainBoard_ID“)
Xml File<run><dom>
…<mainBoard_ID>j6dn2hGH5</mainBoard_ID>…
</dom> <dom>
…<mainBoard_ID>g836gj2hjd</mainBoard_ID>…
</dom></run>
Calendar Page
Moni schedule integrated
Run page – Recent Issues
Run page – Info System
Run page – Report Issues
Run page – Report Dom problems
Run page – Act on issues
Dom Map
ToDo
• Implementation of Sebastians suggestions
• Code Review
• Migration to Madison
• Testing