1. James Michael DuPont
  2. the-anti-corruption-pledge

Commits

James Michael DuPont  committed 5ff75e7

many files

  • Participants
  • Parent commits d5e63a8
  • Branches master

Comments (0)

Files changed (1)

File app/theanticorruptionpledge_csv_export.py

View file
 log = logging.getLogger('CSV Export')
 
 class ExportPledgeCSV(webapp2.RequestHandler):
-    def get(self, state): 
 
+    def export_state(self, state): 
         # Create the file
-        file_name = files.blobstore.create(mime_type='application/octet-stream')
+        file_name = files.blobstore.create(     _blobinfo_uploaded_filename="Export of Data for state %s" % state,      mime_type='application/octet-stream')
         f = files.open(file_name, 'a')
 
         if f is None :
         log.debug( '<h1>Starting to write</h1>')
         self.response.out.write('<h1>Starting to write</h1>') # emit it
         """ Returns a CSV output per state."""
-        if (state == 'ALL') :
-            pledges = models.Pledger.all()
-        else:
-            pledges = models.Pledger.all().filter("state = ", state)
+
+#            pledges = models.Pledger.all()
+#        else:
+        pledges = models.Pledger.all().filter("state = ", state)
+
         self.response.headers['Content-type'] = 'text/plain'        
 
         # this is a list of the fields, they are emitted in that order
             self.response.out.write('<p>%s</p>' % blob_key) # emit it            
             blob_info = blobstore.BlobInfo.get(blob_key)
 
+    def get(self, state): 
+
+        if (state == 'ALL') :
+            for s in models.STATES.keys():
+                log.debug( 'processing state :%s' % s)
+                self.export_state( s)
+        else:
+            self.export_state( state)
+