summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@snark.mit.edu>2009-06-15 17:12:42 -0400
committerbryan newbold <bnewbold@snark.mit.edu>2009-06-15 17:12:42 -0400
commitee1b8ce4f3826c6d7f76a48fdbd0422ea67017bb (patch)
treef94343adf2a5be9840664418149bc1d30a286bad
parentf78236c4113d0d4e5019df316125e86a63befd07 (diff)
downloadequator-ee1b8ce4f3826c6d7f76a48fdbd0422ea67017bb.tar.gz
equator-ee1b8ce4f3826c6d7f76a48fdbd0422ea67017bb.zip
more; BROKENappengine
-rwxr-xr-xdownload_data_local.sh26
-rw-r--r--equations/models.py16
-rw-r--r--index.yaml18
-rw-r--r--load_export.py23
-rw-r--r--templates/about.html2
-rw-r--r--templates/index.html5
-rwxr-xr-xupload_data_local.sh26
-rwxr-xr-xupload_data_remote.sh23
-rw-r--r--urls.py4
9 files changed, 126 insertions, 17 deletions
diff --git a/download_data_local.sh b/download_data_local.sh
new file mode 100755
index 0000000..2711cca
--- /dev/null
+++ b/download_data_local.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+export DJANGO_SETTINGS_MODULE='settings'
+
+appcfg.py download_data \
+ --config_file=load_export.py \
+ --filename=./local_data_symbols.csv \
+ --kind=Symbol \
+ --url=http://localhost:8000/remote_api \
+ .
+
+appcfg.py download_data \
+ --config_file=load_export.py \
+ --filename=./local_data_variables.csv \
+ --kind=Variable \
+ --url=http://localhost:8000/remote_api \
+ .
+
+appcfg.py download_data \
+ --config_file=load_export.py \
+ --filename=./local_data_equations.csv \
+ --kind=Equation \
+ --url=http://localhost:8000/remote_api \
+ .
+
+rm bulkloader-*
diff --git a/equations/models.py b/equations/models.py
index f4be69e..2e517cd 100644
--- a/equations/models.py
+++ b/equations/models.py
@@ -1,8 +1,8 @@
#from django.db import models
from django.utils.translation import gettext_lazy as _
-import django.contrib.auth.models as auth
-from django.conf import settings
-from django.dispatch import dispatcher
+#import django.contrib.auth.models as auth
+#from django.conf import settings
+#from django.dispatch import dispatcher
#from django.db.models import signals
#from signals import update_render
from appengine_django.models import BaseModel
@@ -36,7 +36,7 @@ class Variable(BaseModel):
latex = db.TextProperty(_("Raw LaTeX"))
unicode = db.TextProperty(_("Unicode Representation"))
description = db.TextProperty(_("Description"))
- references = db.ListProperty(db.LinkProperty(_("Reference URL")))
+ references = db.ListProperty(db.Link)
symbol = db.ReferenceProperty(Symbol)
isgeneric = db.BooleanProperty(_("Is Generic?"), default=False)
@@ -59,13 +59,13 @@ class Equation(BaseModel):
latex = db.TextProperty(_("Raw LaTeX"))
unicode = db.TextProperty(_("Unicode Representation"))
description = db.TextProperty(_("Description"))
- created = db.DateTimeProperty(_("Created"), auto_now_add=True)
- updated = db.DateTimeProperty(_("Last Updated"), auto_now_add=True)
+ created = db.DateProperty(_("Created"), auto_now_add=True)
+ updated = db.DateProperty(_("Last Updated"), auto_now_add=True)
#owner = models.ForeignKey(auth.User, verbose_name=_("Owner"))
variables = db.ListProperty(db.Key, verbose_name="Variables")
- references = db.ListProperty(db.LinkProperty(_("Reference URL")))
- userurl = db.db.LinkProperty(_("Last User URL"))
+ references = db.ListProperty(db.Link)
+ userurl = db.LinkProperty(_("Last User URL"))
class Meta:
get_latest_by = 'created'
diff --git a/index.yaml b/index.yaml
index a3b9e05..df0cd6e 100644
--- a/index.yaml
+++ b/index.yaml
@@ -9,3 +9,21 @@ indexes:
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
+
+# Used 2 times in query history.
+- kind: Equation
+ properties:
+ - name: __key__
+ direction: desc
+
+# Used 36 times in query history.
+- kind: Symbol
+ properties:
+ - name: __key__
+ direction: desc
+
+# Used 10 times in query history.
+- kind: Variable
+ properties:
+ - name: __key__
+ direction: desc
diff --git a/load_export.py b/load_export.py
index ab05b55..dbe028a 100644
--- a/load_export.py
+++ b/load_export.py
@@ -2,9 +2,14 @@ import datetime
from google.appengine.ext import db
from google.appengine.tools import bulkloader
from google.appengine.api import datastore_types
+
+import sys
+sys.path.append("/home/bnewbold/code/equator")
+from appengine_django import InstallAppengineHelperForDjango
+InstallAppengineHelperForDjango()
from equations.models import *
-dstr = '%m/%d/%Y'
+dstr = '%Y-%m-%d'
class SymbolLoader(bulkloader.Loader):
def __init__(self):
@@ -31,11 +36,12 @@ class VariableLoader(bulkloader.Loader):
('description', str),
('symbol', str),
('references', str.split),
- ('isgeneric', boolean),
+ ('isgeneric', bool),
])
def HandleEntity(self, entity):
- f = Symbol.all().filter("name =", entity['symbol']).get()
+ print entity['symbol']
+ s = Symbol.all().filter("name =", entity['symbol']).get()
entity['symbol'] = f.key()
reflist = []
@@ -44,6 +50,7 @@ class VariableLoader(bulkloader.Loader):
r = datastore_types.Link(ref)
reflist.append(r)
entity['references'] = reflist
+ return entity
class VariableExporter(bulkloader.Exporter):
def __init__(self):
@@ -87,6 +94,7 @@ class EquationLoader(bulkloader.Loader):
r = datastore_types.Link(ref)
reflist.append(r)
entity['references'] = reflist
+ return entity
class EquationExporter(bulkloader.Exporter):
def __init__(self):
@@ -102,5 +110,14 @@ class EquationExporter(bulkloader.Exporter):
('userurl', str, None),
])
+ #def HandleEntity(self, entity):
+ # vlist = []
+ # vs = entity['variables']
+ # for v in vs:
+ # vlist.append(v.key().get())
+ # entity['variables'] = vlist
+ # print vlist
+ # return entity
+
loaders = [SymbolLoader, VariableLoader, EquationLoader]
exporters= [SymbolExporter, VariableExporter, EquationExporter]
diff --git a/templates/about.html b/templates/about.html
index 3f59846..37c6f79 100644
--- a/templates/about.html
+++ b/templates/about.html
@@ -17,7 +17,7 @@ symbols and variables as json (poke around and you'll find it); i'd like to
offer full export in a bunch of formats as well as feeds for new/special
equations.
-<h2>Stuff that is out there</h2>
+<h3>Stuff that is out there</h3>
<ul>
<li /><a href="http://en.wikipedia.org/">wikipedia</a>
<li /><a href="http://hyperphysics.phy-astr.gsu.edu/hbase/HFrame.html">hyperphysics</a>
diff --git a/templates/index.html b/templates/index.html
index 0ff29f8..b6a3e63 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -6,9 +6,6 @@
padding: 5px; background-color: orange; font-size: 30px; text-align: center;">
<a href="/go/" style="text-decoration:none;">GO</a></div>
<br />
-<h3>View all <a href="/equation/">equations</a>,
-<a href="/variable/">variables</a>, or
-<a href="/symbol/">symbols</a>.</h3>
<p />
This site is a junky hack of a tool to quickly explore equations of all kinds;
the main interface is designed to quickly look up physical equations and
@@ -24,7 +21,7 @@ symbols and variables as json (poke around and you'll find it); i'd like to
offer full export in a bunch of formats as well as feeds for new/special
equations.
-<h2>Stuff that is out there</h2>
+<h3>Stuff that is out there</h3>
<ul>
<li /><a href="http://en.wikipedia.org/">wikipedia</a>
<li /><a href="http://hyperphysics.phy-astr.gsu.edu/hbase/HFrame.html">hyperphysics</a>
diff --git a/upload_data_local.sh b/upload_data_local.sh
new file mode 100755
index 0000000..95b1fd5
--- /dev/null
+++ b/upload_data_local.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+export DJANGO_SETTINGS_MODULE='settings'
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_symbols.csv \
+ --kind=Symbol \
+ --url=http://localhost:8000/remote_api \
+ .
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_variables.csv \
+ --kind=Variable \
+ --url=http://localhost:8000/remote_api \
+ .
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_equations.csv \
+ --kind=Equation \
+ --url=http://localhost:8000/remote_api \
+ .
+
+rm bulkloader-*
diff --git a/upload_data_remote.sh b/upload_data_remote.sh
new file mode 100755
index 0000000..eff1a57
--- /dev/null
+++ b/upload_data_remote.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+export DJANGO_SETTINGS_MODULE='settings'
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_symbols.csv \
+ --kind=Symbol \
+ .
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_variables.csv \
+ --kind=Variable \
+ .
+
+appcfg.py upload_data \
+ --config_file=load_export.py \
+ --filename=./local_data_equations.csv \
+ --kind=Equation \
+ .
+
+rm bulkloader-*
diff --git a/urls.py b/urls.py
index 3a6829a..f839bcd 100644
--- a/urls.py
+++ b/urls.py
@@ -10,7 +10,9 @@ urlpatterns = patterns('',
{'template': 'index.html'}),
(r'^go/', 'django.views.generic.simple.direct_to_template',
{'template': 'go.html'}),
- (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ (r'^about/', 'django.views.generic.simple.direct_to_template',
+ {'template': 'about.html'}),
+ #(r'^admin/doc/', include('django.contrib.admindocs.urls')),
#(r'^admin/(.*)', admin.site.root),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),