Prefs File and Config.py file compatibility

Overview

The St James Software jLogbook and jBrowser applications use prefs files to specify the various configuration parameters. (jLogbook.prefs and jBrowser.prefs) Earlier versions used the config.py format which was a python program to specify these items. The advantage of the prefs file is that there will shortly be a GUI editor available to edit the (sometimes difficult) format of the file. This section shows how the older statements in the config.py file can be transferred into the newer format. The table below shows side by side equivalent examples for the two formats. Note that the indenting is important for both the config.py and the prefs file. (Note that spaces have been added to clarify some of the entries.)

 

config.py format
prefs file format
from jLogbook.python import jlogbook importmodules:
  jlogbook = 'jLogbook.python.jlogbook'
class Demo(common):
  DBNAME = 'jLogbookDemo.mdb'
  DBHOST = None
  DBUSER = "admin"
  DBPASSWORD = ""
  DBPROVIDER = "Microsoft.Jet.OLEDB.4.0"
  DBTYPE = "access"
  attachmentsdir = "c:\\temp\\attachments"
  sessionkey='demo-change'
  gridrefreshinterval=30
  formheight=40
  gridheight=60
  formlabelalignment = 'right'
  extrafilters='boolean'

Demo = Common:
  DBNAME = "jLogbookDemo.mdb"
  DBHOST = None
  DBUSER = "admin"
  DBPASSWORD = ""
  DBPROVIDER = ADOProviders.AccessProvider
  DBTYPE = "access"
  attachmentsdir = "attachments/demo"
  sessionkey='demo-change'
  gridrefreshinterval=30
  formheight=40
  gridheight=60
  formlabelalignment = 'right'
  extrafilters='boolean'

class common:
  serverclass = jlogbook.jLogbookServer
  errorfile = "C:\\Temp\\error.log"
  tracefile = "C:\\Temp\\trace.log"
  auditfile = "C:\\Temp\\audit.log"
  localedomains = ['jToolkit', 'jLogbook.python']
  localedir = 'C:\\Program Files\\jSuite.py\\localize'
Common:
  serverclass = jlogbook.jLogbookServer
  localedomains = 'jToolkit,jLogbook.python'
  localedir = 'Lib/site-packages/localize'
  errorfile = "jLogbook-error.log"
  tracefile = "jLogbook-trace.log"
  auditfile = "jLogbook-audit.log"

from jLogbook.custom import custname

logtableclass = custname.LogTable

importmodules:
  logrecords = 'jLogbook.python.logrecords'

logtableclass:
  template = custname.LogTable
  templateargs:
    baseclass = logrecords.LogTable

from jLogbook.custom import coname
from jToolkit.widgets import thumbgallery
from jLogbook.python import jlogbook

class CONAME(common):
  logtableclass = mailmessage.LogbookTable
  serverclass =  thumbgallery.ThumbnailServer(jlogbook.jLogbookServer)
  messagetocombo = 'emailto'
  messageconditional = {'nickh@sjsoft.com': 'Always', \
      'nichurley@gmail.com': "Keyword in ('Booster', 'Beam Losses')"}
  messagetemplate = {'subject': 'jLogbook Alert', 'organization': 'CO Name'}
  messagefrom = ('jLogbook Alerter', 'david@telkomsa.net')
  smtpserver = 'smtp.dsl.telkomsa.net'
  gallerydir = 'c:\\'

importmodules:
  jlogbook = 'jLogbook.python.jlogbook'
  coname = 'jLogbook.custom.coname'
  thumbgallery = 'jToolkit.widgets.thumbgallery'

CONAME = Common:
  logtableclass = coname.LogbookTable
  serverclass:
    template = thumbgallery.ThumbnailServer
    templateargs:
      baseclass = jlogbook.jLogbookServer
  messagetemplate:
    subject = 'jLogbook Alert'
    organization = 'CO Name'
  messagefrom:
    jLogbook_Alerter = 'david@telkomsa.net'
  messageto:
    David = 'david@telkomsa.net'
  smtpserver = 'smtp.dsl.telkomsa.net'
  gallerydir = 'c:\\'