From 702a8228de4ff9d5c5108e850f6f4377ec3251f9 Mon Sep 17 00:00:00 2001 From: Roalndo Date: Sun, 24 Mar 2013 00:38:16 -0400 Subject: [PATCH] Some noodling and otherwise masturbatory behavior Serious memory leak which I think is the fault of the Gedcom/Element classes but can't be sure --- flaskapp.py | 2 +- gedcom.py | 53 +------------------------------------------- migra.py | 49 ++++++++++++++++++++++++++++++++++++++-- static/css/migra.css | 25 +++++++++++++++++---- static/js/migra.js | 5 +++-- templates/index.html | 9 ++++---- 6 files changed, 78 insertions(+), 65 deletions(-) diff --git a/flaskapp.py b/flaskapp.py index e2dbcd9..40bcb35 100755 --- a/flaskapp.py +++ b/flaskapp.py @@ -36,7 +36,7 @@ def upload(): file = request.files['gedcom'] if file and __allowed_file(file.filename): - all = migra.processGedcom(file) + all = migra.upload(file) k = session.get('key',None) session['key'] = fileStorage().store_file(all,k) return jsonresponse({'count': len(all.keys())}) diff --git a/gedcom.py b/gedcom.py index 57c4c86..ae3706c 100644 --- a/gedcom.py +++ b/gedcom.py @@ -22,7 +22,7 @@ # # To contact the author, see http://faculty.cs.byu.edu/~zappala -__all__ = ["Gedcom", "Element", "GedcomParseError", "GedcomIndividual" ] +__all__ = ["Gedcom", "Element", "GedcomParseError"] # Global imports import string @@ -704,54 +704,3 @@ def __str__(self): result += ' ' + self.value() return result - -class GedcomIndividual(object): - '''this is a class that is useful for pickling, etc.''' - def __init__(self,e): - if not e.individual(): - raise ValueError, ("the element passed to GedcomIndividual should be an individual") - self.__id = e.pointer() - self.__name = e.full_name() - self.__birth = e.birth() - self.__death = e.death() - self.__sex = e.sex() - self.__marriages = [ { 'spouse': m['spouse'].pointer() if m['spouse'] else None, - 'date': m['date'], - 'place': m['place'] - } for m in e.marriages() ] - parents = e.parents() - self.__father = parents[0].pointer() if parents[0] is not None else None - self.__mother = parents[1].pointer() if parents[1] is not None else None - self.__offspring = [ o.pointer() if o is not None else None for o in e.offspring() ] - - def id(self): - return self.__id - - def name(self): - return self.__name - - def birth(self): - return { 'date': self.__birth[0], 'place': self.__birth[1] } if self.__birth is not None else None - - def death(self): - return { 'date': self.__death[0], 'place': self.__death[1] } if self.__death is not None else None - - - def marriages(self): - return self.__marriages - - def sex(self): - return self.__sex - - def parents(self): - return { 'father': self.__father, 'mother': self.__mother } - - def offspring(self): - return self.__offspring - -class GedcomFamily(object): - '''this is a class that is useful for pickling, etc.''' - def __init__(self,e): - return - - diff --git a/migra.py b/migra.py index 7c2e8db..0fb8081 100755 --- a/migra.py +++ b/migra.py @@ -63,6 +63,51 @@ def __walk_parents(self,person,l): self.__add_link(parent,person) self.__walk_parents(parent, l) + +class GedcomIndividual(object): + '''this is a class that is useful for pickling, etc.''' + def __init__(self,e): + if not e.individual(): + raise ValueError, ("the element passed to GedcomIndividual should be an individual") + self.__id = e.pointer() + self.__name = e.full_name() + self.__birth = e.birth() + self.__death = e.death() + self.__sex = e.sex() + self.__marriages = [ { 'spouse': m['spouse'].pointer() if m['spouse'] else None, + 'date': m['date'], + 'place': m['place'] + } for m in e.marriages() ] + parents = e.parents() + self.__father = parents[0].pointer() if parents[0] is not None else None + self.__mother = parents[1].pointer() if parents[1] is not None else None + self.__offspring = [ o.pointer() if o is not None else None for o in e.offspring() ] + + def id(self): + return self.__id + + def name(self): + return self.__name + + def birth(self): + return { 'date': self.__birth[0], 'place': self.__birth[1] } if self.__birth is not None else None + + def death(self): + return { 'date': self.__death[0], 'place': self.__death[1] } if self.__death is not None else None + + + def marriages(self): + return self.__marriages + + def sex(self): + return self.__sex + + def parents(self): + return { 'father': self.__father, 'mother': self.__mother } + + def offspring(self): + return self.__offspring + class MigraPerson (GedcomIndividual): def __init__(self,e,l=0): #given an element, create a person object @@ -267,7 +312,7 @@ class Migra: def __init__(self): MigraGeocoder() - def processGedcom ( self, file ): + def upload ( self, file ): #the calling function will have gotten the file from the web server and done something with it. #based upon its framework it probably will have saved the file, but who knows? what we need to do: #turn the file into a Gedcom object and then return a reference to it and a reference to the @@ -297,5 +342,5 @@ def walk ( self, dict, id, depth ): def cache ( self, parms ): o = json.loads(parms) - return MigraGeocoder().cache ( MigraLocation(o['name'],o['lat'],o['lng']) ) + return geocoder.cache ( MigraLocation(o['name'],o['lat'],o['lng']) ) diff --git a/static/css/migra.css b/static/css/migra.css index a2ce68c..870fef3 100644 --- a/static/css/migra.css +++ b/static/css/migra.css @@ -4,11 +4,18 @@ html, body { height: 100%; font-family: Georgia, "Times New Roman", Times, serif; background-color: #eeeeff; +-webkit-user-select: none; /* Chrome/Safari */ +-moz-user-select: none; /* Firefox */ +-ms-user-select: none; /* IE10+ */ + +/* Rules below not implemented in browsers yet */ +-o-user-select: none; +user-select: none; } #header { position: absolute; - z-index: 9998; + z-index: 9997; top: 0px; width: 100%; } @@ -31,18 +38,27 @@ html, body { } #buttons { - margin: 0 0 0.5em 0; + font-size: 80%; + position: absolute; + bottom: 90px; + z-index: 9997; + margin: 0.5em 0 0.5em 0; padding: 0.5em 0 0.5em 0; } .pseudobutton { // margin: 0.5em; - color: black; + font-family: "Arial Black", "Helvetica Black", Gadget, sans-serif; + text-decoration: none; + color: white; padding: 0.5em; background-color: #9966ff; border: solid #ff7700 2px; } +.pseudobutton a { +} + #map_canvas { height: 100%; width: 100%; @@ -123,7 +139,7 @@ fieldset label { min-height: 100% !important; height: 100% !important; max-height: 100% !important; - background-color:rgba(0, 0, 0, 0.5); + background-color:rgba(192, 192, 192, 0.5); } #spinner{ @@ -231,3 +247,4 @@ transform:rotate(360deg)} } +"Arial Black", "Helvetica Black", Gadget, sans-serif; \ No newline at end of file diff --git a/static/js/migra.js b/static/js/migra.js index 7fee03f..6631dab 100644 --- a/static/js/migra.js +++ b/static/js/migra.js @@ -433,9 +433,10 @@ function clearMap() Window.overlays.polylines[i].setMap(null); } + Window.data = { people: [], addresses: [] }; + Window.overlays = { markers: [], polylines: [] }; + Window.clusterer.clearMarkers(); - Window.data.people = []; - Window.data.addresses = []; } diff --git a/templates/index.html b/templates/index.html index 8c2ed2c..d6f4bd7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,11 +16,11 @@
+