Shawn Devlin <[EMAIL PROTECTED]> wrote:
>Hello all,
>
>I have an CGI based HTTP API (in Perl) to a database and I am now going
>to port to mod_perl. I am new to this kind of programming and I have a
>couple of questions. The platform is Linux.
First thing to keep in mind is that CGI and mod_perl are two completely
different environments. It is true that Apache::Registry and co. help bridge
the gap, but there are still things to watch out for even then. A simple
one-to-one correspondence in functionality between the two is difficult to
make and probably will not yield an efficient implementation.
>My first thought is to break the API up so that there is a module per
>API call (there are some 70 calls in the API). My reasoning is that I
>can modify existing calls and add new ones without affecting everything
>else. Does this make sense or is it better to have the API as one large
>program as I have it now?
If it's an API, I'd not make one module per function, if by function you mean
a call (e.g., fork() is a function in the Unix kernel API). Instead, I'd
group them by functionality (as in OS/2 - VIO, KBD, DOS, ...). So one module
might handle customer accounts, another handle news items, etc.
You probably want to analyse your application and do some redesign work at a
basic level to take advantage of mod_perl.
>My second question pertains to Apache::DBI. I will ask it here but if
>there is a better forum to ask it please let me know and I will ask it
>there. I want to use Apache::DBI in order to cache database
>connections. If I understand everything that I have read so far (and
>that might be a big if) the various modules should share the same
>database connections while running on the same Apache server. Is this
>correct? I.e. if the API functions 'foo' and 'bar' have both been loaded
>into the same instance of Apache and both use Apache::DBI then they will
>share the same database connection.
This should be true. Connections are maintained on a per-process basis and
are global within that process.
--
James Smith <[EMAIL PROTECTED]>, 979-862-3725
Texas A&M CIS Operating Systems Group, Unix