From ee1b8ce4f3826c6d7f76a48fdbd0422ea67017bb Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Mon, 15 Jun 2009 17:12:42 -0400 Subject: more; BROKEN --- download_data_local.sh | 26 ++++++++++++++++++++++++++ equations/models.py | 16 ++++++++-------- index.yaml | 18 ++++++++++++++++++ load_export.py | 23 ++++++++++++++++++++--- templates/about.html | 2 +- templates/index.html | 5 +---- upload_data_local.sh | 26 ++++++++++++++++++++++++++ upload_data_remote.sh | 23 +++++++++++++++++++++++ urls.py | 4 +++- 9 files changed, 126 insertions(+), 17 deletions(-) create mode 100755 download_data_local.sh create mode 100755 upload_data_local.sh create mode 100755 upload_data_remote.sh 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. -

Stuff that is out there

+

Stuff that is out there