be more specific on update time
[myslice.git] / README
1 This file documents the contents of this module
2
3 Last update 4 sept. 2013
4
5 See the devel/ subdir for more devel-oriented doc.
6
7 ==================== 1 minute howto
8
9 *  REQUIREMENTS  is to have python + django installed django
10 ** should be straightforward
11 ** see devel/django-install.txt in case of trouble
12
13 * git clone git://git.onelab.eu/myslice.git
14 -- or --
15 * git clone ssh://yourlogin@git.onelab.eu/git/myslice.git
16
17 * edit myslice/config.py and enter the details of your manifold backend
18
19 * init django
20 $ manage.py syncdb
21
22 * gather static files
23 $ ./manage.py collectstatic (formerly, we used make static, which is deprecated)
24 -- or --
25 $ ./manage.py collectstatic --noinput
26
27 * run a local server:
28 $ manage.py runserver 0.0.0.0:8000
29 -- or -- my advice:
30 $ devel/server-loop.sh
31 when you just need to hit ^C yourself when your static files need to be refreshed - see below
32
33 * use it from your browser 
34 (See more notes on using the development server below)
35
36 * install dependencies 
37 $ pip install -r path/to/requirements/file.txt
38 Note. not quite sure what this is about, I could not spot this file..
39
40 ==================== Status
41
42 *** Authentication ***
43
44 Should be mostly fine
45 Not quite sure if/how the user gets proper notifications when
46 . his session has expired (i.e. his frontend is not logged into the backend any longer)
47 . his credentials have expired (i.e. the uploaded credentials, e.g. SFA delegated cred)
48   expired and she needs to run e.g. sfi myslice again
49
50 Hard-coded accounts (from a very early stage) are gone
51
52
53 *** Packaging ***
54
55 I've done a very rough attempt at packaging for rpm.
56 The logic seems about right but needs more work, in particular in terms of installing myslice.conf
57 in the httpd conf.d directory. 
58 It seems like our app won't work on f14 as is because Django is only 1.3.1 on f14
59 Plan is to target f18 but I lack a test machine.
60 Also of course I'll try to tackle debian/ubunti at some point.
61
62 There also is a working packaging for debian(s) and ubuntu(s) that we use 
63 on an almost daily basis to upgrade manifold.pl.sophia.inria.fr
64
65
66 ==================== 
67
68 Third party tools shipped:
69
70 * jquery
71 * datatables
72 * spin
73 * bootstrap
74
75 Others are added as we build the system when they become needed
76 Look in third-party/ for a more detailed list
77
78 As a rule of thumb, please try to keep in mind that these will need to
79 be upgraded over time I've tried to keep track of the version I picked
80 and to have an easy upgrade path (depending on the way the original
81 package is published)
82
83 ==================== Contents: 1st level subdirs
84
85 ========== code from git
86
87 * myslice/
88   this is the django 'project', where to look for
89   . settings.py
90   . urls.py
91
92 * manifold/
93   the code for dealing with queries, sending them to the backend, and offering the /manifold/proxy/ URL
94
95 * unfold/
96   the code for building / rendering plugins 
97
98 * plugins/
99   the actual code for plugins
100
101 * auth/ 
102   a django 'app' that deals with authentication; see especially
103   auth.backend.MyCustomBackend 
104   for how to use a separate authentication system, 
105   as well as settings.py for how to enable it
106
107 * portal/
108   this is where the first implementation of myslice, with complete
109   user-management including registration, is taking place
110
111 * trash/
112   rough/preliminary scaffolding views are in here
113   as the name suggests this is temporary
114
115 * views/
116   will receive actual views over time 
117   currently has some global html templates as well
118   + some global static files (css, js, images..)
119
120 * insert_above: 
121   a third-party django app for adding on-the-fly mentions to css or js files that need to go in the header
122
123 * third-party/
124    * third party javascript and css stuff (bootstrapfs, jquery, this kind of things)
125      see more about that below too
126
127 * devel:
128   no code in there, only various notes and other scripts useful for developers
129
130 ========== automatically generated 
131
132 * all-static: (generated, no need to source-control)
133   this is where 'make static' will gather all your static contents if you run a local server
134   make has convenience targets to refresh this area
135   $ make static 
136   $ make clean-static 
137
138 * django-static
139
140 * myslice.sqlite3
141   this is where django stores its own stuff, as per settings.py
142
143 ==================== conventions for templates & static files
144 ==================== and NOTES on using the development server
145
146 . first off, running manage.py runserver is provided by django as a development convenience but
147   SHOULD NOT be used in production
148
149 . second, when you do use it for developement purposes, please be aware that:
150
151 .. the recommended layout for the various files and pieces (py, html, js and css) with django is
152    IMHO really painful; we *SHOULD* use e.g. 
153       plugins/simplelist.py, 
154       plugins/templates/plugins.html,
155       plugins/static/js/simplelist.js 
156       plugins/static/css/simplelist.css
157    which I have tried doing for a while but I found myself just hopping around in the file tree all
158    day long, wasting cycles big time
159
160 .. as that does not make sense IMHO, I've rewritten the tool for gathering these pieces (this is in
161    the Makefile). Bottom line is we can essentially store this wherever we want.
162    The only restriction being that if you have a template that is *not* html, then it *has to* sit
163    in a templates/ directory, otherwise it gets shipped as a static file.  
164
165 .. as a result, we can now store all the files building a plugin in a single (git) directory; like e.g.
166       plugins/quickfilter/quickfilter.py
167       plugins/quickfilter/quickfilter.html
168       plugins/quickfilter/quickfilter.js
169       plugins/quickfilter/quickfilter.css
170
171    Of course it's a completely different matter once the service is packaged and installed, these
172    files of course get properly separated.
173
174 .. as a result it is a little bit less convenient to use the development server when you change the
175    layout of your static and template files, you might need to re-run 'make static', so it is
176    recommended to use devel/server-loop.sh instead
177
178
179 All this being said, here are our current conventions for storing templates and static files
180
181 * templates:
182   we store this under templates/ within the corresponding app, e.g.
183      auth/templates/login.html
184   for now this is mostly about html, but the engine can be used for rendering anything 
185   including js(on) or whatever (in which case, as stated above, this *must* have /templates/ in its path.
186
187 * static files:
188   we chose to have all static files (images, but also javascript and stylesheets) in the various
189   proj or app where they belong, with a layout like:
190   where-it-belongs/
191       img/
192       css/
193       js/
194   Honestly it's not yet very clear sometimes what 'where-it-belongs' should be sometimes, and it
195   does not matter too much anyway, given that the code doesn't need to change when we move things
196   around. So in particular it's fuzzy between myslice/ (where the logo could fit e.g.) views/ and
197   even trash/
198
199 Makefile has a few convenience targets to list all kinds of stuff; the 2 major targets are 
200
201 $ make static templates
202
203 that would reset all-static/ and all-templates/ for you from the other contents
204
205 * third-party
206   please note that the set of files that actually get exposed in all-static from third-party is
207   hand-coded in Makefile because we tried to preserve the original codebase layout from mainstream,
208   and there's only so much in common between 2 differents js libraries at this point.
209
210
211
212 ======== update django database to reflect changes in existing models without any migration system (e.g., south) =========
213
214 $python manage.py reset <your_app>
215 #Django 1.5.1
216 $python manage.py flush
217
218 This will update the database tables for your app, but will completely destroy any data that existed in those tables. 
219 If the changes you made to your app model do not break your old schema (for instance, you added a new, optional field) 
220 you can simply dump the data before and reload it afterwards, like so:
221
222
223 $python manage.py dumpdata <your_app> > temp_data.json
224 $python manage.py reset <your_app>
225 $python manage.py loaddata temp_data.json
226
227 If your changes break your old schema this won't work - in which case tools like south or django evolution are great.