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