More words
[apertium.git] / apertium-forms-server / README
blobac5ab2b13c717f12c6d3326435ebf47334a261c3
1 apertium-forms-server
2 ======================================================
4 ==You need==
6 * python (>= 2.4)
7 * python-4suite-xml (>= 1.0.2)
8 * python-webpy (= 0.22)
10 On debian you can get them by apt-get installing those
11 package names. I'm fairly sure the first two won't change
12 much and break anything, but for python-webpy, as it is 
13 quite alpha, I'm only guarantee'ing with this version.
15 ==Running it==
17 Set up the config file in config/config.xml, then run:
19  $ python apertium-forms-server.py
21 This will daemonise, then navigate to: 
23  http://localhost:8080
25 You can keep adding entries, when you want to save the 
26 entries to the files, navigate to:
28  http://localhost:8080/commit/<pair name>
30 ==Files and directories==
32 The server is broadly laid out along the lines of MVC,
33 although this is broken when and where I please. 
35 * interface.py: Holds the class to generate the HTML.
36 * pair.py: Holds the various classes representing the 
37   parts of the dictionary we need to use.
38 * apertium-forms-server.py: Runs the http servlet, and 
39   controls POST / GET on the forms.
41 There is an extra file, config.py, which loads the config
42 file (normally in config/config.xml) and sets up the 
43 various structures in pair.py.
45 The static/ directory contains javascript and CSS that 
46 needs to be served statically. This needs to be here for
47 webpy to show them
49 The scripts/ directory contains scripts for managing the 
50 forms. At the moment there is only one script:
52 * generate-bidix-templates.py 
54 This script takes as input three dictionaries, and outputs
55 a file containing the bilingual dictionary templates. The
56 templates should be checked before being used, as errors
57 in the dictionaries will be reproduced.
59 ==Using templates==
61 Templates go in the templates/ directory, they are specified
62 in the config.xml file with the entry (under <pair>):
64   <templates file="<filename>"/>
66 Then when a user creates a new entry if a template exists it 
67 will use that, and if not fall back to a simple
69   lemma1<tag>:lemma2<tag>
71 entry.
73 ==Wishlist==
75 * The gloss should really be attached to each paradigm,
76   not to the dictionary.
77 * Writing files is really slow, but it isn't in PHP,
78   what do they do differently? Is this something that can
79   be fixed in cDomlette at the expense of more memory?
80 * In some cases the code is overly complex, possibly 
81   double checking variables. It was written in a hurry. 
82   Probably it would be good to go through each function
83   and check for this sort of thing.
86 ==Coding style==
88 I like braces, they make blocks easier to distinguish. I
89 use them in python even though it often it makes coding 
90 difficult. For example, I try to avoid using if/elif/else
91 blocks, because python does not provide a way to use my 
92 preferred coding style:
94 if x < y: #{
96 #} else: #{
100 So, if possible, try and do the same, sometimes in 
101 desperation I do:
103 if x < y: #{
105 else: #{
109 Probably best to avoid it though.