![]() |
Configuring rest2webThe Config FileConfiguring
r2w.py ../path/to/r2w.ini The options all look something like : start_directory = "../../source_directory" The quotes are optional. Note rest2web uses ConfigObj to read config files. ConfigObj uses a very simple ini style syntax. If you want to check out the full syntax spec, you'll need to read the ConfigObj Docs. As well as the options in the config file, you can also control some of rest2web's behaviour through Command Line options. Config OptionsThe basic list of config options is :
The options are explained in the config file, but there is also a full explanation below. The config options are case sensitive. The only one that is optional is DEBUG, all the other options must be present or restweb will fail. In addition to these, you can also specify uservalues in the config file. See the uservalues section below. Directory Paths
rest2web reads source files and outputs HTML. THhe directory it reads files from is the - 'start_directory'. This will be the top level for your website. It also needs to know where to put the files it generates - the 'target_directory'. The directory structure of the resulting website will be created in the 'target_directory'. Existing files will be overwritten without confirmation, but files that don't need to be overwritten won't be deleted. When rest2web generates files it compares them against existing files to see if the file has changed. This can be useful if you want your target directory to only contain files that have changed (for uploading the new and changed files by FTP). In this case you may want to specify a 'compare_directory' that is different from the 'target_directory'. If you don't specify a 'compare_directory' (set the value to '') then the 'target_directory' is used. log_file'log_file' is the path to a file for logging the results of running rest2web. This includes any errors that may occur. If you set it to '' then no log file will be generated. skiperrorsThis option determines how rest2web will handle exceptions (like our old friend UnicodeDecodeError) that happen when processing pages. If set to True, rest2web will display the error and move to the next file. The default is False. Note If an error occurs whilst trying to process an index file, it will have to skip building the directory. This feature is still 'experimental' and may need refining. macrosThis option is the path to an optional 'macros' file. rest2web has a standard set of default macros built into it. You can also create additional macros in an external file. This option specifies the path to your macros file. It should be a file called 'macros.py'. For details of how this works, please see the macros page. This option allows you to have different macro files for all the sites that you create with rest2web. If you set it to '', then no macros file will be used for this site. Macro PathsThe default macros include smiley and emoticon. They provide very easy ways to include smilies and small images in your pages. In order to do this rest2web needs to know the filepath to your smiley directory and the URL paths to the smilies and images on your website. These options are specified in a section called Macro Paths : [Macro Paths] smiley_directory = '' smiley_url = '<% path_to_root %>images/smilies/' emoticon_url = '<% path_to_root %>images/' If you are using the standard set of smilies supplied with rest2web, then you need not supply a path to the smiley directory, as in the example above. See the macros page for details of all the default macros. psyco'psyco' should be set to True or False. If True, rest2web will attempt to use psyco.full(). If you have psyco installed rest2web runs faster, but I have had a problem with psyco reported on one Linux platform. Not having psyco installled and setting this value to True will have no effect. It won't prevent rest2web from running though. Note If you want psyco for windoze, the latest version is only available from SVN repository. You can obtain precompiled binaries for windows from www.voidspace.org.uk/python/modules.shtml#psyco. pause'pause' should be set to True or False. If True, after finishing rest2web will wait for the user to hit enter before exiting. This can be ueful on the Windoze platform where you launch rest2web by double clicking on r2w.py. DEBUGThis value is optional. 'DEBUG' should be set to True or False. If True, then before rendering each page rest2web will drop you into an interactive interpreter session inside the namespace of the page. As well as all the normal values in the namespace there is an exit() function which calls sys.exit(). You also have the values local_vars, self and temp_file. These are the local variables from where the namespace was built, the processor object, and the template file. UservaluesUservalues are values that use in your pages and templates, using the rest2web Templating system. You can set uservalues in individual pages. By using a single page template and different uservalues you can easily have different translations of the same content without having to reproduce the structure of each page. See Uservalues for more details. You can also store uservalues in your config file. These are 'global' uservalues which are available in every page. You could put things like your program version number, or a site title in here, and use in any of your pages. They should appear in the config file in a section called uservalues. Like this : [uservalues] site_title = My Program Documentation version = 1.0.0 You can then use this in your pages or templates, like this : Welcome to <% site_title %>. This is version <% version %>. If your uservalues contain non-ascii characters, you can specify the encoding with a special value : __encoding__. For example, to specify the UTF-8 character set : [uservalues] __encoding__ = UTF-8 site_title = My Program Documentation version = 1.0.0
Return to Top |
||