Skip to content

Instantly share code, notes, and snippets.

@kindly
kindly / lib.activity
Created November 4, 2011 10:41
start of activity for ckan.
from sqlalchemy.orm.session import SessionExtension
class DatasetActivitySessionExtension(SessionExtension):
def before_commit(self, session):
session.flush()
try:
obj_cache = session._object_cache
revision = session.revision
@kindly
kindly / ckan-datastore.py
Created March 1, 2012 22:07 — forked from rufuspollock/ckan-datastore.py
CKAN DataStore client
#!/usr/bin/env python
import urlparse
import mimetypes
import os
import ConfigParser
import urllib2
import json
import csv
import time
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>mooooooooooooooooooooooooooooooo</h1>
</body>
* example of how to provide the data according to the new vocabulary version
{
"id": "32d432-42342-42342242", # our id not allowed on create, has to be supplied on update
"name": "dataset-name", # madatory and has restrictions to [a-zA-Z1-9-_]*
"title": "dataset title", # if empty same as name
"alternative_title": "alternative title",
"description": "long description",
"keyword_string": "keyword1, keyword2, keyword2", # comma seperated keywords
@kindly
kindly / gist:2637431
Created May 8, 2012 17:09
nginx sample config for datastore
server {
listen 80 default;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location / {
# location of apache or ckan under paster
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
@kindly
kindly / apache virtual host.
Created May 24, 2012 15:50
Sample apache configuration for running ckan side by side with drupal.
<VirtualHost *:80>
ServerName test.ckan.org
ServerAlias test.ckan.org localhost
#Drupal instance
DocumentRoot /var/www/drupal
DirectoryIndex index.phtml index.html index.php index.htm
# CKAN lives under /data
WSGIScriptAlias /data /dir/to/wsgi.py
@kindly
kindly / gist:2787470
Created May 25, 2012 11:32
site lockdown extension
def site_read(context, data_dict=None):
model = context['model']
user = context['user']
userobj = model.User.get( user )
if userobj:
return {'success': True}
return {'success': False, 'msg': 'You must be logged in see the site'}
class YourExtension(SigletonPlugin):
import sqlalchemy
import uuid
_engines = {}
_pg_types = {}
def get_engine(context, data_dict):
db_name = data_dict.get('db_name', 'main')
engine = _engines.get(db_name)
import requests
import time
import glob
result = glob.glob('/home/david/Downloads/json/*')
def run_documents():
for document in result:
print document
import os
import sys
import pkg_resources
import paste.script.appinstall
from paste.deploy import loadapp
import paste.fixture
import time
import csv
import cProfile
import requests