From: Jamie C. <jca...@we...> - 2008-05-31 05:55:28
|
Hi Fran, Webmin is pretty flexible in what it lets you do in your .cgi scripts, although the further you get away from the 'standard' (which I admit is itself non-standard in Perl terms), the harder it can be to call other modules or make use of Webmin's access control systems and API. Some things that are quite safe are using 'use CGI' instead of ReadParse and generating output with HTML::Template. However, if you don't use web-lib.pl in the normal way or skip calling init_config, some features of Webmin won't work, such as module-level access control and checking for links from dangerous referers. Other developers could probably comment better here though, as being the author of Webmin I have always pretty much stuck to my own standards for core and non-core modules :-) - Jamie On 30/May/2008 12:35 Fran Fabrizio wrote .. > > I've just inherited a half-dozen or so custom modules from a team member > who departed. Looking at his code, it seems that he did not really > adhere to the style found in the documentation for module developers. > For instance, each module has its own perl module (ex. Cisweb.pm) and > therefore its own namespace. He also does 'use strict' in all of his > .pm and .cgi files, imports the module via use instead of require, > doesn't use the %config hash, uses CGI.pm instead of ReadParse, he's > used HTML::Template to separate HTML from logic, and so on. > > I'd like to bring this code back in line with more standard webmin > module development practices, and I'm trying to decide the best way to > rework this code. Some of the things he's done aren't inherently bad > yet create difficulty in the webmin environment. I like the idea of > using .pm's and therefore private namespaces, but this does complicate > matters a bit because any require '../web-lib.pl' stuff is now going to > populate the private namespace instead. I like the idea of doing use > strict, but this means I'm then going to need to do use vars qw(%config > %in) if I want to do things like ReadParse and init_config(). I like > the idea of HTML::Template, and that actually seems to work pretty > cleanly as-is. Nevertheless, it's all seeming a bit messy. :-) > > So my question is simply whether anyone has developed an alternative set > of practices to what's in the module devel docs that incorporates some > of these practices. I understand that a lot of webmin's style is > "dated" because of the desire to support as many platforms and > environments as possible, but I have full control over the environment > I'm running in and actually would prefer to do this with modules and > perhaps ultimately more of an OO style of coding, and I always prefer to > do use strict, and suppose I will even with the use vars qw() extra > legwork. I'm just curious if any of the more seasoned module devels > have suggestions about how to bridge webmin's style with what I'm more > used to seeing in my perl experience. |