|
|
| Author |
Message |
BorisL Cacti User
Joined: 31 Mar 2007 Posts: 55
|
Posted: Fri Jun 05, 2009 8:16 am Post subject: INCLUDE statement to include other config files |
|
|
Hello!
Here's patch that enables INCLUDE command that will allow to include some other config file into another.
Typically it is handy to store template options in some "header" files.
Syntax:
| Code: | | INCLUDE configs/some_themplate_file.conf |
| Description: |
|
 Download |
| Filename: |
INCLUDE.patch |
| Filesize: |
2.23 KB |
| Downloaded: |
55 Time(s) |
|
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 3437 Location: United Kingdom
|
Posted: Fri Jun 05, 2009 9:23 am Post subject: |
|
|
I won't be including this patch in the normal release because it will cause problems with the editor. The editor has no way to tell if the config came from an include or not, so the first time you use the editor to edit the map, you'll lose the include, and have all of it's contents in the main file.
I do agree that it would be a useful feature, but it's not quite so simple to add
|
|
| Back to top |
|
 |
BorisL Cacti User
Joined: 31 Mar 2007 Posts: 55
|
Posted: Fri Jun 05, 2009 12:20 pm Post subject: |
|
|
Hmm,
(IN|OUT)BWFORMAT are copied from 'LINK TEMPLATE' the first time config is saved. So I thought some features can be set accurately through text config only .
Is there any way to disable visual editor (for writing only) for particular config file? Weathermap can detect INCLUDE statement(s) and control this ability.
edit:
that logic can be implemented as WeatherMap object property (storing INCLUDE presence status) and check in WriteConfig().
|
|
| Back to top |
|
 |
BorisL Cacti User
Joined: 31 Mar 2007 Posts: 55
|
Posted: Fri Jun 05, 2009 12:52 pm Post subject: |
|
|
New version of patch: disallow writing new config when current map was build from config file with INCLUDE statement.
| Description: |
|
 Download |
| Filename: |
INCLUDE.patch |
| Filesize: |
2.92 KB |
| Downloaded: |
63 Time(s) |
|
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 3437 Location: United Kingdom
|
Posted: Sun Jun 14, 2009 12:38 pm Post subject: |
|
|
I've been playing with this a little today. Now each node and link knows which file it was defined in, so WriteConfig will skip nodes or links that weren't defined in the 'main file'. It will also add 'INCLUDE blah.conf' lines for all included files.
I added a restriction that INCLUDE will ONLY be allowed in the global section, so that I don't need to track the state of the parser so much. If you had some nodes, then an include, then the last node before the include would be defined somewhere different in the order than you expected. Since templates are done at ReadConfig time currently, that might be a problem.
The remaining problem is global commands like BACKGROUND or SCALE commands, or font definitions. They will still get written into the main file if they were defined in the include.
However, since the includes are placed at the end of the global section by WriteConfig, whatever is in them will override any settings in the main file. This means the include will 'stick' OK, but will make the editor a little confusing. I think that it's probably good enough for now though.
If you use INCLUDE only to define templates, or to add standard nodes for company logo etc, then the editor will work completely normally.
Sometime soon I'll be changing the templates stuff to work at runtime instead, which means that some ordering restrictions will go away, and hopefully the parser can be a bit smarter about things like preserving comments and order.
|
|
| Back to top |
|
 |
|