Skip to content

Instantly share code, notes, and snippets.

@veriojon
veriojon / oai_server.py
Created May 15, 2013 19:59
flask server
#from lxml import etree
from flask import Flask, request, Response, render_template, abort
from oaipmh import server, metadata
from oai_auth import auth_info, ip_check_init, ip_to_inst, set_auth, get_ip
import logging
import ss_server
def getServer():
myserver = ss_server.BatchingSharedShelfServerBase()
@veriojon
veriojon / ss_server.py
Created May 15, 2013 19:53
server code
from oaipmh import common, error
from oaipmh.datestamp import datestamp_to_datetime
from datetime import datetime
from flask import abort
from dateutil import parser
import requests
import json
import pytz
import logging
import memcache
In [2]: from imata.libs.elastic_search import SearchEngine
In [3]: SearchEngine.reindex()
2011-08-03 10:22:24,744 INFO [urllib3.connectionpool][MainThread] Starting new HTTP connection (1): localhost
Rebuilding ES index, please wait.
/Users/jon/Env/lib/python2.7/site-packages/sqlalchemy/engine/default.py:518: SAWarning: Unicode type received non-unicode bind param value.
param[key.encode(encoding)] = processors[key](compiled_params[key])
Indexing 6, 8 assets.
Indexing 7, 9 assets.
ERROR: An unexpected error occurred while tokenizing input
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 58146)
----------------------------------------
2011-04-12 11:09:57,048 INFO [imata.views.asset][worker 0] ([[u'SSID', u'Filename', u'Artstor Classification[1816]', u'Work Type[1821]', u'Creator[1822]', u'Culture[1814]', u'Title[1815]', u'Title 2[1823]', u'Title 3[1824]', u'Title 4[1825]', u'Style/Period[1826]', u'Date[1827]', u'Date extent[1832]', u'Date type[1829]', u'Earliest Date[1819]', u'Latest Date[1820]', u'Materials[1830]', u'Techniques[1831]', u'Measurements[1828]', u'Location[1817]', u'Location type[1846]', u'Subject[1842]', u'Relationships[1844]', u'Image View Type[1840]', u'Image View Description[1835]', u'Image agent[1833]', u'Image Date[1845]', u'Image subject[1836]', u'Order number[1837]', u'ID Number[1834]', u'Old ID number[1839]', u'Legacy data notes[1841]', u'Requestor id[1838]', u'Source[1843]', u'Rights[1818]', u'Subject 2[1847]', u'PlayDate[2087]'], ['38023', u'foo.jpg', '', '', u
@veriojon
veriojon / gist:895635
Created March 31, 2011 01:11
date stuff again
def is_valid(self, value):
# try:
if parser.parse(value).year < 1900:
fail("Year is below min value of 1900 for field '%s'" % self.label)
return True
# except:
# fail("Invalid date for field '%s'" % self.label)
@veriojon
veriojon / gist:856054
Created March 5, 2011 03:00
excel error stuff
var ErrorListView = new Ext.list.ListView({
store: ExcelErrorStore,
autoScroll: true,
columns: [{
header: 'SSID',
width: .2,
dataIndex: 'ssid'
},{
header: 'Error Type',
width: .3,
@veriojon
veriojon / gist:851637
Created March 2, 2011 20:08
box with panel
var ExcelErrorDialog = Ext.extend(Ext.Window, {
constructor: function(config) {
this.importerrorForm = new Ext.FormPanel({
frame: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side'},
// items: [{
// xtype: 'displayfield',
// itemID: 'numerrors',
@veriojon
veriojon / gist:847897
Created February 28, 2011 19:49
excel display agin
var ExcelSuccessDialog = Ext.extend(Ext.Window, {
constructor: function(config) {
this.importsuccessForm = new Ext.FormPanel({
frame: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side'},
items: [{
xtype: 'displayfield',
itemID: 'numnew',
function uploadSuccess(file, data, resp) {
Imata.log("Upload done: "+ file);
Imata.log("data: "+ data);
Imata.log("response: "+ resp);
var record = assetTempStore.getById(file.id);
Imata.log("test: " + record.get('status'));
Imata.log("file: " + file.id)
record.set('status', 'Failed');
record.commit();
def check_for_existing_session(self):
log.critical("in check_for_existing_session")
#print dir(session)
#print session.keys()
#print session["_id"]
if "userid" in session:
log.critical("userid in session")
return dict(logged_in=True, username=session['username'], institution=session['institution_name'])
else:
# check if cookie set