User:Andre Castro/prototyping/1.2/traces: Difference between revisions

From XPUB & Lens-Based wiki
Line 43: Line 43:


According the date decide what part of story will be told
According the date decide what part of story will be told
<source lang="python">
#! /usr/bin/python
import lxml.etree, urllib2
#Script which parses xml database. Checks the dates and email address under each date
f = ('/home/andre/server-pzi/cgi-bin/traces-email-database.xml') # change to local
#f = urllib2.urlopen('http://pzwart3.wdka.hro.nl/~acastro/cgi-bin/traces-email-database.xml') #ERROR! ??permissions
doc = lxml.etree.parse(f)
print  lxml.etree.tostring(doc)
# for emails under the date 20120217 -> send PART#1
# find dates
dates = doc.xpath('//@date')
# for each date send one given part
date_is = doc.xpath("//date[@date='20120217']")
address = doc.xpath("//date[@date='20120217']/address/text()")
for nodes in doc.xpath("//date[@date='20120217']/address/text()"):
print "Send email to " +  nodes
#email then sent
<source>


   
   

Revision as of 19:03, 17 February 2012

ok bambino

1st part seems to working


******part1******

Form and email / date appending email-database.xml

  • online form
  • cgi receives email address and appends it to email-database.xml file

email-database.xml:

<email-address>
  <entries>
		<date date="20120216">
			<address>test@test.org</address>
			<address>test2@test.org</address>
		</date>
  </entries>
</email-address>
  • links:

http://pzwart3.wdka.hro.nl/~acastro/form/email-form.html

http://pzwart3.wdka.hro.nl/~acastro/cgi-bin/email_form_handler.cgi

******part2******

Days and Emails calculations

Other py script which:

  • parse the email-database.xml (every day)

Script which parses xml database. Checks the dates and email address under each dat3.

According the date decide what part of story will be told

<source lang="python">

  1. ! /usr/bin/python

import lxml.etree, urllib2

  1. Script which parses xml database. Checks the dates and email address under each date


f = ('/home/andre/server-pzi/cgi-bin/traces-email-database.xml') # change to local

  1. f = urllib2.urlopen('http://pzwart3.wdka.hro.nl/~acastro/cgi-bin/traces-email-database.xml') #ERROR! ??permissions


doc = lxml.etree.parse(f) print lxml.etree.tostring(doc)

  1. for emails under the date 20120217 -> send PART#1
  1. find dates

dates = doc.xpath('//@date')

  1. for each date send one given part

date_is = doc.xpath("//date[@date='20120217']")

address = doc.xpath("//date[@date='20120217']/address/text()")


for nodes in doc.xpath("//date[@date='20120217']/address/text()"): print "Send email to " + nodes #email then sent


<source>


  • check the dates
  • see what section of the text needs to send to whom

******part2******

Email the sections