Skip to content

Commit

Permalink
Some noodling and otherwise masturbatory behavior
Browse files Browse the repository at this point in the history
Serious memory leak which I think is the fault of the Gedcom/Element
classes but can't be sure
  • Loading branch information
rolando3 committed Mar 24, 2013
1 parent 5f44a59 commit 702a822
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 65 deletions.
2 changes: 1 addition & 1 deletion flaskapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())})
Expand Down
53 changes: 1 addition & 52 deletions gedcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


49 changes: 47 additions & 2 deletions migra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']) )

25 changes: 21 additions & 4 deletions static/css/migra.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
Expand All @@ -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%;
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -231,3 +247,4 @@ transform:rotate(360deg)}

}

"Arial Black", "Helvetica Black", Gadget, sans-serif;
5 changes: 3 additions & 2 deletions static/js/migra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

}

Expand Down
9 changes: 5 additions & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<section id="map_section">
<div id="header"><h1>Migra ancestry mapping</h1></div>
<div id="map_canvas"></div>
<div id="buttons">
<a id="btn_restart" href="#" class="pseudobutton">Upload a new file</a>
<a id="btn_choose" href="#" class="pseudobutton">Choose a new focus</a>
</div>
<div id="footer">
<div id="buttons">
<a id="btn_restart" href="#" class="pseudobutton">Upload a new file</a>
<a id="btn_choose" href="#" class="pseudobutton">Choose a new focus</a>
</div>
<div id="statusBar" style="display: table-row; width: 100%">
<div id="message_pad" class="statusbar_cell" style="width: 50%">Ready.</div>
<div class="statusbar_cell" style="width: 30%">
Expand All @@ -47,6 +47,7 @@
-->

<div id="overlay">
<div id="header"><h1>Migra ancestry mapping</h1></div>
<div id="upload_form_wrapper" class="dialog" style="display: none;" >
<form id="upload_form" enctype="multipart/form-data" action="/upload" >
<fieldset>
Expand Down

0 comments on commit 702a822

Please sign in to comment.