Commits

Anonymous committed cba3bbb

fix a few attribute names no longer private after 1.1, and allow *args and **kwargs in __call__ method to fix usage in urls.py

  • Participants
  • Parent commits 81aeaea

Comments (0)

Files changed (1)

shapes/views/export.py

         self.mimetype = mimetype
         self.file_name = file_name
 
-    def __call__(self):
+    def __call__(self, *args, **kwargs):
         """
         """
         fields = self.queryset.model._meta.fields
         ds = ogr.OGR_Dr_CreateDataSource(dr._ptr, tmp.name, None)
         
         # Get the right geometry type number for ogr
-        ogr_type = OGRGeomType(geo_field._geom).num
+        if hasattr(geo_field,'geom_type'):
+            ogr_type = OGRGeomType(geo_field.geom_type).num
+        else:
+            ogr_type = OGRGeomType(geo_field._geom).num
 
         # Set up the spatial reference with epsg code
-        srs = SpatialReference(geo_field._srid)
+        if hasattr(geo_field,'srid'):
+            srs = SpatialReference(geo_field.srid)
+        else:
+            srs = SpatialReference(geo_field._srid)
         
         # If true we're going to reproject later on 
         if self.proj_transform:
         zip = zipfile.ZipFile(buffer, 'w', zipfile.ZIP_DEFLATED)
         files = ['shp','shx','prj','dbf']
         for item in files:
-            filename= '%s.%s' % (tmp.name.strip('.shp'), item)
-            zip.write(filename, arcname='%s.%s' % (self.file_name.rstrip('.shp'), item))
+            filename= '%s.%s' % (tmp.name.replace('.shp',''), item)
+            zip.write(filename, arcname='%s.%s' % (self.file_name.replace('.shp',''), item))
         if self.readme:
             zip.writestr('README.txt',self.readme)
         zip.close()
         
         # Stick it all in a django HttpResponse
         response = HttpResponse()
-        response['Content-Disposition'] = 'filename=%s.zip' % self.file_name.rstrip('.shp')
+        response['Content-Disposition'] = 'attachment; filename=%s.zip' % self.file_name.replace('.shp','')
         response['Content-length'] = str(len(zip_stream))
         response['Content-Type'] = self.mimetype
         response.write(zip_stream)