The Application ini file and the wwServerConfig class
The application INI file contains settings that the Web Connection server and your individual process modules need for operation. It can also contain custom settings that you want to store for your own application specific purposes.
The server settings are required while the process module settings are optional and can be defined by you as you need them. By default Web Connection manages the INI file settings through a custom implementation of the wwServerConfig class (defined in wwServer.prg and subclasses from the wwConfig class) which dynamically manages the settings via an object that persists its properties into the INI file.
The application INI file has the same name as the project. So the demo application is wcDemo and the ini file is wcDemo.ini. The Ini file looks like this:
[Main] tempfilepath=c:\temp\ template=wc_ logtofile=On saverequestfiles=Off showrequestdata=Off showserverform=On showstatus=On usemts=Off scriptmode=3 timerinterval=200 firstname.lastname@example.org adminmailserver=mail.gorge.net adminsenderroremail=Off [wwdemo] datapath=d:\wwapps\wc3\wwDemo\ htmlpagepath=d:\westwind\wconnect\ [http] datapath=d:\wwapps\wc3\wwDemo\ htmlpagepath=d:\westwind\wconnect\ serverport=80 adminaccount=rstrahl
The [Main] section contains server settings. Any other sections like [wwdemo] and [http] map to process classes that you implement. You can add any custom values to these INI files as you see fit. Please see the wwServerConfig object for more detailed information on the individual keys.
The wwConfig objectThe Ini file is driven through the wwConfig object, which is an object persistance class. Basically wwConfig can persist all of its members into XML, an INI file or a registry string. wwConfig is used to hold all the server configuration settings and a subclass of this object is automatically created for you in your mainline program like wcDemoMain.
Skip to the bottom of wcDemoMain.prg to find this code:
DEFINE CLASS wcDemoConfig as wwServerConfig owwDemo = .NULL. owwMaint = .NULL. oWebHits = .NULL. oHTTP = .NULL. FUNCTION Init THIS.owwDemo = CREATE("wwDemoConfig") THIS.owwMaint = CREATE("wwDemoConfig") THIS.oHTTP = CREATE("HTTPConfig") THIS.oWebHits = CREATE("WebHitsConfig") ENDFUNC ENDDEFINE DEFINE CLASS wwDemoConfig as RELATION cHTMLPagePath = "d:\westwind\wconnect\" cDATAPath = "d:\wwapps\wc3\wwDemo\" ENDDEFINE DEFINE CLASS httpConfig as RELATION cHTMLPagePath = "d:\westwind\wconnect\" cDATAPath = "d:\wwapps\wc3\wwDemo\" cServerPort = "80" cAdminAccount = "rstrahl" ENDDEFINE
The main wcDemoConfig object is the 'server' config object which becomes accessible as Server.oConfig (it's based on wwServerConfig which you can find in wwServer.prg). It contains server start up settings like the temp path, templates, timeouts and so on that are a required part of the Web Connection server. You can add additional properties if you want them to be available on the server object.
If you change a value in the INI file, the value is read on server startup and the class value is changed to the INI file value - if the INI value doesn't exist the default property value is used.
Notice that each of the sub-process classes get a custom object that is attached to the main server config object. For example, oHTTP is simply a new object with properties that match your INI file settings you want to create. Every property you add becomes a key value.
To add any other sections simply create another class with the properties you want to use and the wwConfig class will take care of the rest.
Note that the New Project and New Process Wizards handle creating of the basic objects for you automatically. All you have to do is add your custom properties to persist in the INI file.
Important: All properties you create should be created with a type prefix like cServerPort, cDataPath, nSeconds. The prefix is dropped when written out to the INI file. If you omit the prefix you'll run into truncated values in the INI file - it'll still work, but it sure will look funny.
See alsoClass wwServerConfig
Comment or report problem with topic