Added Readme.md, cleaned up config.py.tmpl and settings.py, started working on comparing categories (unfinished) in utils.py
authorNicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
Fri, 12 Dec 2014 16:45:47 +0100
changeset 10 7d016d52be36
parent 9 893799c494e2
child 11 f2d54d2841f3
Added Readme.md, cleaned up config.py.tmpl and settings.py, started working on comparing categories (unfinished) in utils.py
Readme.md
dev/Puppet_Readme.md
src/catedit/config.py.tmpl
src/catedit/settings.py
src/catedit/utils.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Readme.md	Fri Dec 12 16:45:47 2014 +0100
@@ -0,0 +1,63 @@
+# Catedit
+
+This document will present the structure of the project and dev environment, the different steps to setup a CatEdit server, and what is needed to run it.
+
+### The dev environment
+
+** Vagrant + Puppet : **
+After cloning the project repository, you will find a [readme](dev/Puppet_Readme.md) file for Vagrant and Puppet in the /dev folder. Most of the setup of CatEdit dev environment happens in the /dev folder with the exception of the python plugin list located in /virtualenv/requirements.txt
+
+** Project structure : **
+
+Here is the structure of the project directory:
+
+* /dev/ has all the puppet/vagrant files and scripts to set up dev environment
+* /src/catedit/ contains the source files
+* /src/catedit/static/ contains the static files (js, css ...)
+* /src/catedit/template/ contains the html templates
+* /virtualenv/ contains the list of python packages
+
+### How to setup a server
+
+** Github config : **  You need a working github repository to use the application. The best way to do this is to have an app admin Github account that will handle all the repository administration. Aside from a working repository, you also need to register the app on github. To do this, you just have to go to your Github settings/applications and register a new application. You will need the "client ID" and "client secret" Github will generate for setting up the config.py file later.
+
+As this app works using the Github API, all the users must have a Github account to edit categories. The users must also be added as collaborators to the categories repository by the repository owner you defined.
+
+** Setting up config.py : **
+In the /src/catedit/ folder, you will find a config.py.tmpl. This file is the template of a mandatory config.py file that is used to set up the config of the application. Here are the values you can change in it:
+
+* HOST : The host on which the app will run, default is "0.0.0.0" for development purpose as "localhost" won't work with vagrant and windows.
+* LOGGING : Wether or not the app write log files
+* DEBUG : Wether or not the app is on debug mode. If True, then each modification of a given file will restart the server allowing for easy development.
+* REPOSITORY_NAME : The name of the repository your app will use to store categories
+* REPOSITORY_OWNER : The name of the owner of the repository (typically a "admin" user)
+* CATEGORIES_PATH : Where on the repository categories will be stored. Default to /categories
+* GITHUB_CLIENT_ID : The client ID Github gave you when you registered the app
+* GITHUB_CLIENT_SECRET : The client secret Github gave you when you registered the app
+
+Once you have set up all the constants you need, save the file as config.py in the /src/catedit folder.
+
+** Starting up the server **
+: Once you have a config.py file ready, you can start the server by running the following command from the /src/catedit folder:
+
+    python main.py
+
+## Additional/Advanced informations ##
+
+** Changing the property list : ** If you want to change the property list available to users editing/creating categories, you have to put the following entry in config.py
+
+* PROPERTY_LIST : My list of properties ...
+
+The list of property has a fixed structure. The property list is a dict of python dicts, each following the fixed structure:
+
+    "propertyKey" : {
+        "descriptive_label_fr" : "mylabelfr",
+        "descriptive_label_en" : "mylabelen",
+        "object_type": "my-object-type",
+        "rdflib_class": some-RDFLib-concept,
+        "object_rdflib_class": some-RDFLib-class,
+    }
+
+* "object_type" : "my-object-type",  -> either "literal", "uriref-category" or "uriref-link" at the moment
+* "rdflib_class" : some-RDFLib-concept, -> a rdflib class of some sort with its namespace, examples: SKOS.related or RDF.Type representing the predicate
+* "object_rdflib_class" : some-RDFLib-class:  -> a rdflib class representing the object, either Literal or URIRef
--- a/dev/Puppet_Readme.md	Tue Dec 09 12:39:38 2014 +0100
+++ b/dev/Puppet_Readme.md	Fri Dec 12 16:45:47 2014 +0100
@@ -40,12 +40,6 @@
 
 Your /root/ directory will be located on the virtual machine in the /srv/ directory.
 
-You can then run the following command (from the /srv/root/src directory) for testing purpose:
-
-    python manage.py runserver 0.0.0.0:8000
-
-You'll have to open a browser page to 127.0.0.1:8001 to see your test site.
-
 ###Notes and known bugs
 
 Windows users can experience a bug with shared folder (shared folders would only work the first time you setup the vm) due to the way Windows (doesn't) handle symlinks. Here are the steps to fix it manually:
--- a/src/catedit/config.py.tmpl	Tue Dec 09 12:39:38 2014 +0100
+++ b/src/catedit/config.py.tmpl	Fri Dec 12 16:45:47 2014 +0100
@@ -3,9 +3,15 @@
 
     DEBUG = False
     LOGGING = False
+    SERVER_NAME = "0.0.0.0"
 
-    # Repository settings
+    # Github repository settings
 
     REPOSITORY_NAME = "habitabilite-prototype"
     REPOSITORY_OWNER = "catedit-system"
     CATEGORIES_PATH = "categories/"
+
+    # Github parameters
+
+    GITHUB_CLIENT_ID = "3e31f3b000a4914f75ef"
+    GITHUB_CLIENT_SECRET = "bc17eb0ec11385628c2e75aacb5ff8ef5f29e490"
--- a/src/catedit/settings.py	Tue Dec 09 12:39:38 2014 +0100
+++ b/src/catedit/settings.py	Fri Dec 12 16:45:47 2014 +0100
@@ -8,7 +8,6 @@
 
     HOST = "0.0.0.0"
     DEBUG = True
-    LOGGING = False
     LOGGING_LEVEL = "DEBUG"
 
     # WTForms settings
--- a/src/catedit/utils.py	Tue Dec 09 12:39:38 2014 +0100
+++ b/src/catedit/utils.py	Fri Dec 12 16:45:47 2014 +0100
@@ -1,13 +1,22 @@
 from flask.ext.restful import abort
-from models import Category
+from models import Category, CategoryManager
+from rdflib.compare import *
 
-# def check_if_cat_exists(catID):
-#     idInGraph=False
-#     catToReturn="NotFound"
-#     for cat in categories:
-#         if cat.catID == catID:
-#             idInGraph=True
-#             catToReturn=cat
-#     if not(idInGraph):
-#         abort(404, message="Category doesn't exist")
-#     return catToReturn
+'''
+    This function will compare two categories from their Graph object serializations
+    Exact return values are to be defined, some ideas
+    * check if the 2 categories are the same? (same ID, isomorphic)
+    * check if the 2 categories are the same but different version? (same ID, not isomorphic)
+    * check if unique, non empty parameters changed and list them (label and description)
+    * returns 2 lists of properties: only_in_first, only_in_second
+    * more?
+'''
+
+def compare_two_cat(cat_serial_1, cat_serial_2):
+    cat1 = Category(cat_serial_1)
+    cat2 = Category(cat_serial_2)
+    iso_cat1 = cat1.cat_graph.to_isomorphic()
+    iso_cat2 = cat2.cat_graph.to_isomorphic()
+    if iso_cat1 != iso_cat2:
+        in_both_cats, only_in_cat1, only_in_cat2 = graph_diff(cat1, cat2)
+    return