Library enabling to use triple store with Django - django

I need to create quickly a simple web application - an interface for querying a triple store. Previously I made such an application with Django for querying a graph database Neo4j, I used the Neomodel package for binding Django and Neo4j.
Is there such a package for using Django with a triple store? I have already installed Fuseki and have my data in turtle format.
On this page: http://csarven.ca/how-to-create-a-linked-data-site it is explained how to to do what I need but using PHP, which I have no notion of. Since I don't have much time to waste, I would prefer to work with the pythonic Django, already familiar to me.

If you want to work with Django, you're lucky, because Python has a libary that helps you to work with triple store, called RDFlib, based on RDF. RDFlib Docs
The Resource Description Framework (RDF) is a family of World Wide Web Consortium (W3C) specifications originally designed as a metadata data model. It has come to be used as a general method for conceptual description or modeling of information that is implemented in web resources, using a variety of syntax notations and data serialization formats. It is also used in knowledge management applications. Wikipedia
Working specifically in Django, it's hard to give a guideline because the question is wide. Maybe you can find some packages to help you in Django Packages

Related

Django & Mongo ORM mapping

I have a Django project with a MongoDB, connecting through pymongo.
I've looked into several ORM(-like) layers, but none of them seem well maintained or supporting the Django 1.8 (mongo-engine only supports Django 1.5, mongokit is no longer maintained, and the other libraries seem to have no real community behind them).
So I think I'll be just using pymongo, which means that there is quite some things I'll need to implement myself, for example validation (checking that every document inserted in a collection has the required fields and field types).
How would I go about this?
Are there any example projects that I can take a look at?
I found this project which connects from Django directly to Mongo, but there is not much structure in it.
Use PyMODM. As the docs you linked to say, "PyMODM is an ORM-like framework on top of PyMongo. PyMODM is maintained by engineers at MongoDB, Inc. and is quick to adopt new MongoDB features. PyMODM is a “core” ODM, meaning that it provides simple, extensible functionality that can be leveraged by other libraries to target platforms like Django. At the same time, PyMODM is powerful enough to be used for developing applications on its own. Complete documentation is available on readthedocs in addition to a Gitter channel for discussing the project."
https://api.mongodb.com/python/3.4.0/tools.html

Ember.js backend setup

I'm currently wrapping my head around Ember.js and converting a previously written PHP application, that application made use of of mysql database and some basic PHP code to display results.
There was a whole bunch of javascript to create interactions, but all that code quickly became unusable.
I have most of my frontend stuff done in Ember.js and started thinking about how I should get started with the backend.
There's not that much data involved, uses can request data, create new data, change data or delete data.
There would be a small part where I would like to get data in real time.
I've looked around on the web, but since it's all relatively new, there's not that much information out there.
I would recommend implementing a RESTful API in PHP and hooking your frontend up with that API. You can use your ember code to handle all user interaction, and then when some actual data needs to be changed send a request to your backend.
I have made apps in the past using this strategy with a Laravel backend which makes it very simple to set up RESTful interactions.
You can read about Ember + REST here: http://emberjs.com/guides/models/the-rest-adapter/
The question is quite vague as you could do it in a thousands different ways.
It doesn't matter which language you use for the backend as the ember app won't care.
The only thing you need for the Ember app to work is a decent REST api.
For resource about best practices, check this
Some examples:
In php: http://davss.com/tech/php-rest-api-frameworks/
In Rails: http://railscasts.com/episodes?utf8=✓&search=api
In Node express: http://blog.modulus.io/nodejs-and-express-create-rest-api
As a Saas: https://www.firebase.com
I have been living with an EmberLoopSql stack (pronounced ember-loop-cicle - just cause I like the sound) for 4 months now and am digging it muchly.
StrongLoop allows you to reverse engineer your datastore, creating models that correspond to tables, and automatically creating a CRUD ReST API for them. This means there is no code in your API, just configuration.
Add the loopback-component-jsonapi to StrongLoop to provide json:api compliant responses.
Next, add relationships to your StrongLoop models - like bubbling up the foreign key relationships from the datastore to the api. Now you have json:api responses that Ember really loves.
I am a big fan of Percona Server (MySQL replacement) and if you de-normalize your tables to align with your application, you have one of the main advantages of a NoSQL style datastore. But if you really like something like Mongo (I do), StrongLoop has a data juggler for that.. as well as for most modern datastores.
Ember's new JSONAPIAdapter recognizes relationships exposed in the json:api responses from StrongLoop. After setting up relationships in your models - again bubbling up datastore foreign keys - Ember will fetch dependencies automatically for you. E.g. If you have model a,b and a hasMany b, you can use a.b in your templates and Ember will understand the relationship and fetch the data for you.
What I really love about this stack is how much boilerplate code just evaporates. Compared with java, php, express, go, etc. the code in this stack is small and well organized. I can implement new features in a couple of hours instead of a couple of days.
Hope these opinions help...

How to migrate Django project to Google App Engine

I am looking for a guide to migrate Django project to Google App Engine and use Google's datastore. The most of the guides I found were linked to Django-Appengine using Django-nonrel (but I want to use GAE's native support).
Going through GAE getting started guide, it says:
Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor), including Django, CherryPy, Pylons, web.py, and web2py. You can bundle a framework of your choosing with your application code by copying its code into your application directory.
I understand that I won't be able to use some features of Django in that case (majorly the admin feature) and would also need to restructure the models.
From other reading, I also found that latest SDK of GAE now includes Django 1.3 on Python 2.5.
I tried to put all files from my Django application to a GAE project, but couldn't get it all to work together.
Please provide some basic guide using which I may migrate my Django project to Google App Engine's code.
Thanks.
For an existing Django app, using django-nonrel is the simplest approach; it is very popular so you should be able to find help with specific errors you get quickly.
Another approach is written up in this article: http://code.google.com/appengine/articles/pure_django.html -- it goes the other way, taking an App Engine app that uses Django for dispatch, templates, and forms, but not for models, and describes how to make it run in a native Django environment. Maybe you can glean some useful hints for your situation from it.
I've used django-nonrel, which behaves pretty much like django, except that operations with JOINs will return errors. I've basically worked around this by avoiding ManyToMany fields, and essentially building that functionality manually with an intermediate table.
So far I've ran into two problems with Django-nonrel:
1. No access to ancestor queries, which can be run in a transaction. There's a pending pull request for this feature though.
2. You can't specify fields that are not indexed. This could significantly increase your write costs. I have an idea to fix this, but I haven't done so yet.
(Edit: You CAN specify fields that are not indexed, and I've verified this works well).
2 (new). Google is pushing a new database backend called ndb that does automatic caching and batching, which will not be available with django-nonrel.
If you decide not to use django-nonrel, the main differences are that Django models do not run under App Engine. You'll have to rewrite your models to inherit from App Engine's db.Model. Your forms that use Django's ModelForm will need to inherit from google.appengine.ext.db.djangoforms instead. Once you're on App Engine, you'd have to port back Django if you ever take your app somewher else.
If you already have a Django application you might want to check this out. You won't work with App Engine's datastore but Google Cloud SQL might fit your needs.

What is a simple way to make a basic website with graph database backend for newbie?

Graph database systems like ne04j seem to becoming very popular of late. I am a newbie user who is trying to set-up a website that needs to display some data which is best displayed using a graph database (essentially i will visualize this on the website).
I am designing this website using CMS Drupal but i am open to changing to other CMS or in worst case a web application framework like Django. Can anyone suggest me a basic template, website or extension to a CMS that enable graph databases or a good way to start learning web app development using graph databases for a noob ?
Well, if you're curious about using Drupal to manage graphs, I'd recommend looking over these contributed modules:
http://drupal.org/project/graphapi
http://drupal.org/project/charts
http://drupal.org/project/views_charts
http://drupal.org/project/charts_graphs
There is http://structr.org/, a CMS built on Neo4j and very Open and capable. Other bindings, you might take a look at REST bindings and neo4j embedded bindings to get going.
If you're looking for even more alternatives for charting in Drupal, then you may want to start from the Comparison of charting module, which includes information and links about quite a lot of charting related modules in Drupal.
If you're aware of other modules not included in it, please update that docu if you can, or let me know about it.

Whats the advantage of using a package to create a RESTful API interface

I am creating a simple RESTful interface on one of my apps and I have been looking at what's available out there:
I've looked at:
django-piston but it seems abandoned and the feedback on it is not great.
django-dynamicresponse which seems rather bare
A lot of packages from here
However, looking at examples of how these packages it seems that they don't really provide much. It's really not that hard to create a list of URL mappings and use something like simplejson to return a response...
Is there an advantage to using one of these packages that I am missing?
This question may be similar to Django and Restful APIs but it has been a while since that one had any new answers, and I want to find out whether it is worth to use a package at all.
Thanks
If you are writing one API for one or two simple models for "internal" use (eg, for the AJAX frontend of your app to communicate with the backend vs. an API exposed to external clients), then frameworks like django-piston or Tastypie might be overkill compared to writing one or two views and using simplejson.
Where the frameworks start to really pull their own weight is when you have more complicated requirements. Some examples:
you have a complicated model with a lot of relations (think nested tree structures)
you need to support multiple serializations (XML, YAML, Plists, or JSONP in addition to JSON)
you want to version your API
you want to do restrict access for some operations (eg, to provide read-only access to certain clients)
you want to throttle or rate-limit client access
Many of those aren't a big deal on a small, simple project where you control both ends, but become very important when you're thinking about making an external API to your service.