NAME
MPMinus::Manual - What is MPMinus, and how do I use it?
VERSION
version 1.12
TERMS
- Apache
-
WEB-ñåðâåð Apache. Ýòîò WEB-ñåðâåð ÿâëÿåòñÿ åäèíñòâåííûì ñåðâåðîì, ïîääåðæèâàþùèì MPMinus. MPMinus ðàçðàáîòàí íà îñíîâå ìîäåëÿ mod_perl2, êàê ìîäóëü Apache.
DESCRIPTION
MPMinus (MPM) - mod_perl2 Web Application Framework
MPMinus - Ôðåéìâîðê äëÿ ðàçðàáîòêè ñàéòîâ ñ âûñîêîé íàãðóçêîé. MPMinus ðàññ÷èòàí äëÿ ñïåöèàëèñòîâ, ðàáîòàþùèõ ñî ñâÿçêîé òåõíîëîãèé Apache + mod_perl2. Áîëüøèíñòâî áàçîâûõ òåõíîëîãèé, èñïîëüçóþùèåñÿ â ðàáîòå ýòîé ñâÿçêè, ýòèì äîêóìåíòîì íå ðàññìàòðèâàþòñÿ. Äëÿ ïîëó÷åíèÿ áîëåå ïîäðîáíîé èíôîðìàöèè î âîïðîñàõ ñâÿçàííûõ ñ mod_perl2, Apache è Perl, îáðàùàéòåñü ê ñîîòâåòñòâóþùèì ñïðàâî÷íûì ðóêîâîäñòâàì ýòèõ òåõíîëîãèé.  çàäà÷è ýòîãî ïîñîáèÿ âõîäèò ïîäðîáíîå îïèñàíèå ðàáîòû MPMinus.
CATALYST AND MPMINUS
Èíîãäà ðàçðàáîò÷èêè ïðèâîäÿò àíàëîãèþ MPMinus ñ ñèñòåìîé Catalyst. Òàêàÿ àíàëîãèÿ ìîæåò áûòü ñïîðíîé, ò.ê. ýòî àáñîëþòíî äâå ðàçíûå ñèñòåìû. Ñèñòåìà Catalyst ýòî ñèñòåìà êîòîðàÿ ïðèçâàíà îáúåäèíèòü êîìïîíåíòû Model, View è Controller â îäíî öåëîå; êîãäà êàê ñèñòåìà MPMinus îáúåäåíÿò ëèøü ìåòîäû äîñòóïà ê îáúåêòàì óðîâíåé Model, View è Controller.
Íî ñðàçó õîòåëîñü áû îãîâîðèòüñÿ, ÷òî áîëüøàÿ ÷àñòü èäåé ïðèíÿòûõ ðàçðàáîò÷èêàìè Catalyst, ïðèÿíòî è ïðîåêòîì MPMinus, ÷òî ïîçâîëÿåò ãîâîðèòü î ðàçâèòèè ïðîåêòîâ â îäíîì íàïðàâëåíèè.
DISPATCHING, URI DISPATCHER
Äèñïåò÷åðèçàöèÿ îáåñïå÷èâàåò URL-to-Action ìåõàíèçì îáðàáîòêè êëèåíòñêèõ çàïðîñîâ. Ìåõàíèçì îñíîâàí íà òîì ôàêòå, ÷òî â çàâèñèìîñòè îò ïåðåäàííîãî URL âûïîëíÿåòñÿ òî èëè èíîå äåéñòâèå íà ñòîðîíå MPMinus. Íà òåêóùèé ìîìåíò èñïîëüçóåò URL(URI) äèñïåò÷åðèçàöèÿ. Ñàì URI Äèñïåò÷åð îáåñïå÷èâàåò äèñïåò÷åðèçàöèþ çàïðîñîâ êëèåíòà èñõîäÿ èç ðÿäà òèïîâ äèñïåò÷åðèçàöèè:
Location, Regexp, LocArr è MixArr.
Êàæäûé èç ýòèõ òèïîâ ñëóæèò äëÿ äèñïåò÷åðèçàöèè ðàçëè÷íûõ çàïðîñîâ èñõîäÿ èç òåêóùèõ òðåáîâàíèé ðàçðàáàòûâàåìîãî ñàéòà. Ïîäðîáíåå î ðàçëè÷èÿõ òèïîâ äèñïåò÷åðèçàöèè ñì. íèæå.
Íàñòðîéêà äèñïåò÷åðèçàöèè âûïîëíÿåòñÿ â äâóõ ìåñòûõ: â êîíôèãóðàöèîííîì ôàéëå ïðîåêòà è íåïîñðåäñòâåííî â ìîäóëå îáðàáîò÷èêîâ (õýíäëåðîâ) îæèäàåìûõ äåéñòâèé.
- Location
-
Ýòà äèñïåò÷åðèçàöèÿ âûðàæàåòñÿ â ïðÿìîì ñîïîñòàâëåíèè - "Çàïðîøåíûé URI" == "Çíà÷åíèå".
Íàïðèìåð: "/" == "/"
Äëÿ âêëþ÷åíèÿ â ðàáîòó òàêîé äèñïåò÷åðèçàöèè ñëåäóåò ñäåëàòü ñëåäóþùèå èçìåíåíèÿ â êîíôèãóðàöèè Apache:
<Location ~ ^/$> PerlInitHandler ModPerl::MySite::Handlers </Location>
È, ñîîòâåòñòâåííî, â ìîäóëå ModPerl::MySite::Root:
sub record { ( -uri => '/', ... ) }
Äèñïåò÷åðèçàöèÿ Location íàèáîëåå ïðîñòà â îáðàáîòêå è ÿâëÿåòñÿ ýòàëîíîì ïðîèçâîäèòåëüíîñòè. Ýòîò òèï äèñïåò÷åðèçàöèè ïîäõîäèò äëÿ áîëüøèíñòâà ñàéòîâ, ðàçðàáàòûâàþùèõñÿ ñ èñïîëüçîâàíèåì MPMinus.
- Regexp
-
Ýòà äèñïåò÷åðèçàöèÿ âûðàæàåòñÿ â ñîïîñòàâëåíèè - "Çàïðîøåíûé URI" =~ "Regexp".
Íàïðèìåð: "/0123456789abcdef" =~ /^\/[a-zA-Z0-9]{16}\/?$/
Äëÿ âêëþ÷åíèÿ â ðàáîòó òàêîé äèñïåò÷åðèçàöèè ñëåäóåò ñäåëàòü ñëåäóþùèå èçìåíåíèÿ â êîíôèãóðàöèè Apache:
<Location ~ ^\/[a-zA-Z0-9]{16}\/?$> PerlInitHandler ModPerl::MySite::Handlers </Location>
È, ñîîòâåòñòâåííî, â ìîäóëå ModPerl::MySite::Root:
sub record { ( -uri => ['REGEXP', 'root.mpm', qr/^\/[a-zA-Z0-9]{16}\/?$/], ... ) }
Ãäå REGEXP - Êëþ÷ òèïà äèñïåò÷åðèçàöèè. Êëþ÷è òèïîâ äèñïåò÷åðèçàöèè ðåãèñòðîíåçàâèñèìû.
- LocArr
-
Ýòà äèñïåò÷åðèçàöèÿ âûðàæàåòñÿ â îáðàòíîì ñîïîñòàâëåíèè õàðàêòåðíîì äëÿ íåñêîëüêèõ âàðèàíòîâ URI èç ñïèñêà, êàê - "Çàïðîøåíûé URI" == "Îäíî èç çíà÷åíèé ñïèñêà".
Íàïðèìåð: "/" == ("/","/root.mpm","/index.mpm")[0]
Äëÿ âêëþ÷åíèÿ â ðàáîòó òàêîé äèñïåò÷åðèçàöèè ñëåäóåò ñäåëàòü ñëåäóþùèå èçìåíåíèÿ â êîíôèãóðàöèè Apache:
<Location ~ \.[mM][pP][mM]$> PerlInitHandler ModPerl::MySite::Handlers </Location> <Location ~ ^/$> PerlInitHandler ModPerl::MySite::Handlers </Location>
È, ñîîòâåòñòâåííî, â ìîäóëå ModPerl::MySite::Root:
sub record { ( -uri => ['LOCARR', 'root.mpm', ['/','/root.mpm','/index.mpm']], ... ) }
- MixArr
-
Ýòà ñìåøàííàÿ äèñïåò÷åðèçàöèÿ, âûðàæàåòñÿ â îáðàòíîì ñîïîñòàâëåíèè - "Çàïðîøåíûå URI" = "Îáðàáîò÷èê" èëè "(Çàïðîøåíûå URI) =~ Regexp".
Íàïðèìåð: "/" (==,=~) ("/",qr/^\/(root|index)\.mpm$/)
Äëÿ âêëþ÷åíèÿ â ðàáîòó òàêîé äèñïåò÷åðèçàöèè ñëåäóåò ñäåëàòü ñëåäóþùèå èçìåíåíèÿ â êîíôèãóðàöèè Apache:
<Location ~ \.[mM][pP][mM]$> PerlInitHandler ModPerl::MySite::Handlers </Location> <Location ~ ^/$> PerlInitHandler ModPerl::MySite::Handlers </Location>
È, ñîîòâåòñòâåííî, â ìîäóëå ModPerl::MySite::Root:
sub record { ( -uri => ['MIXARR', 'root.mpm', ['/',qr/^\/(root|index)\.mpm$/]], ... ) }
CONFIGURATION
Êîíôèãóðàöèîííûå ïàðàìåòðû èíèöèàëèçèðóþòñÿ â ïðîåêòîì ìîäóëå ModPerl::MySite::Handlers ñ ïîìîùüþ ïðèíóäèòåëüíîãî âûçîâà:
sub handler {
my $r = shift;
my $m = MPMinus->m;
$m->conf_init($r, __PACKAGE__);
...
my $project = $m->conf('project');
...
}
Äëÿ äîñòóïà ê äàííûì êîíôèãóðàöèè (ïåðåìåííûì âåëè÷èíàì) ñóùåñòâóåò ðÿä ìåòîäîâ:
$m->conf('NAME') - Ïîëó÷åíèå çíà÷åíèå ïåðåìåííîé NAME èç õýøà êîíôèãóðàöèè
my $cfg = $m->get('conf') - Ïîëó÷åíèå ññûëêè íà õýø êîíôèãóðàöèè
Ïðè ðàáîòå ñ ïðîåêòàìè ñëåäóåò ðàçëè÷àòü óðîâíè óñòàíîâêè òåõ èëè èíûõ ïåðåìåííûõ.
Áîëåå ïîäðîáíóþ èíôîðìàöèþ ñì. MPMinus::Configuration
APACHE LEVEL
Óðîâåíü ïðîöåññîâ Apache (httpd).
Ïåðåìåííûå ýòîãî óðîâíÿ ÿâëÿþòñÿ îáùèìè ïåðåìåííûìè äëÿ âñåõ ïðîåêòîâ MPMinus. Ê òàêèì ïåðåìåííûì ñëåäóåò îòíîñèòü: íåèçìåíÿåìûå ïîëüçîâàòåëåì çíà÷åíèÿ, óñòàíîâëåííûå â êîíôèãóðàöèîííûõ ôàéëàõ Apache: *.conf. Äîñòóï ê ýòèì ïåðåìåííûì ìîæíî ïîëó÷èòü ñ ïîìîùüþ ìåòîäîâ mod_perl. Ñì. http://perl.apache.org/docs/index.html
REQUEST LEVEL
Ïåðåìåííûå ýòîãî óðîâíÿ èçìåíÿþòñÿ ïðè êàæäîì êëèåíòñêîì çàïðîñå, ýòè ïåðåìåíûå êîíñòðóèðóþòñÿ íà ëåòó, ê íèì îòíîñÿòñÿ, â ÷àñòíîñòè, çíà÷åíèÿ ïåðåìåííîé ñðåäû îêðóæåíèÿ $ENV.
sid - 16-òè çíà÷íîå 16-òèðè÷íîå ÷èñëî, èäåíòèôèêàòîð çàïðîñà (MPMinus-ñåññèè)
hitime - Äàòà è âðåìÿ â ìèëèñåêóíäàõ ìîìåíòà çàïðîñà
package - Ïàðà çíà÷åíèé: èìÿ ïàêåòà è êîëè÷åñòâî èíèöèèðîâàííûõ çàïðîñîâ íà äàííûé ïðîöåññ Apache
project - Èìÿ ïðîåêòà ÍÅ â ñòàíäàðòå UNIX (ñ ó÷åòîì ðåãèñòðà)
prefix - Èìÿ ïðîåêòà â ñòàíäàðòå UNIX (êàê ðåçóëüòàò âûðàæåíèÿ lc(project)). Ýòî çíà÷åíèå
èñïîëüçóåòñÿ êàê ïðåôèêñ ïðîåêòà äëÿ íóæä ãåíåðàöèè ôàéëîâ, êàòàëîãîâ è äðóãîé ñòàòè÷åñêîé
èíôîðìàöèè.
request_uri - Ñòðîêà çàïðîñà, URI
request_method - Ìåòîä çàïðîñà
remote_user - Ëîãèí ïîëüçîâàòåëÿ (HTTP)
remote_addr - IP àäðåñ ïîëüçîâàòåëÿ (HTTP)
http_host - Äîìåííîå èìÿ ñàéòà ê êîòîðîìó îñóùåñòâëÿåòñÿ îáðàùåíèå.
Äëÿ íåñòàíäàðòíûõ ïîðòîâ ñòðîèòñÿ êàê: server_name[:server_port]
server_admin - Àäðåñ e-mail àäìèíèñòðàòîðà ïðîåêòà, maintainer
server_name - Äîìåííîå èìÿ ñàéòà (âèðòóàëüíîãî õîñòà), çàäàííîå äèðåêòèâîé ServerName
server_port - Íîìåð èñïîëüçóåìîãî ïîðòà (âèðòóàëüíîãî õîñòà)
document_root - Êîðíåâàÿ ïàïêà ïðîåêòà äîñòóïíàÿ èç âíå (àáñîëþòíûé áàçîâûé ïóòü).
Èñïîëüçóåòñÿ ðàçðàáîò÷èêîì ïðîåêòîâ êàê áàçîâûé ïóòü äî êîðíÿ ñàéòà ïðîåêòà.
modperl_root - Àáñîëþòíûé áàçîâûé ïóòü äî êîðíÿ ïðîåêòà. Ýòîò ïóòü èñïîëüçóåòñÿ äëÿ
ñèñòåìíûõ íóæä è ïðèìåíÿåòñÿ äëÿ ãåíåðèðîâàíèÿ ñèñòåìíûõ ïàïîê è ôàéëîâ
äëÿ èñïîëüçîâàíèÿ ïî óìîë÷àíèþ. Ïîëåçíî èñïîëüçîâàòü äëÿ îáúåäèíåíèÿ âñåõ
ñàéòîâ îñíîâàííûõ íà MPMinus ïî ÷àñòè ëîãîâ è êîíôèãóðàöèé.
PROJECT LEVEL
Óðîâåíü ïðîåêòà.
Ïåðåìåííûå ýòîãî óðîâíÿ åäèíû äëÿ âñåõ ýêçåìïëÿðîâ êîíêðåòíîãî ïðîåêòà.
dir_conf - Äèðåêòîðèÿ êîíôèãóðàöèè (conf)
dir_cache - Äèðåêòîðèÿ êýøà (cache)
dir_logs - Äèðåêòîðèÿ ëîãîâ ïðîåêòà (log)
dir_db - Äèðåêòîðèÿ ëîêàëüíûõ ÁÄ (db)
dir_shtml - Äèðåêòîðèÿ øàáëîíîâ SSI (shtml)
fileconf - Ïóòü ê ôàéëó êîíôèãóðàöèè <prefix>.conf
file_error - Èìÿ ôàéëà ëîãà îøèáîê (òîëüêî èìÿ): mpminus-<prefix>_error.log
file_debug - Èìÿ ôàéëà ëîãà ñîîáùåíèé îòëàäêè (òîëüêî èìÿ): mpminus-<prefix>_debug.log
logdir - Ïóòü äî êàòàëîãà ëîãîâ (àáñîëþòíûé ïóòü)
confdir - Ïóòü äî êàòàëîãà êîíôèãóðàöèè (àáñîëþòíûé ïóòü)
errorlog - Ïóòü äî ôàéëà ëîãà îøèáîê (àáñîëþòíûé ïóòü)
debuglog - Ïóòü äî ôàéëà ëîãà ñîîáùåíèé îòëàäêè (àáñîëþòíûé ïóòü)
url - Àäðåñ ñàéòà ïðîåêòà HTTP äëÿ íóæä ðåäèðåêòîâ è âíóòðåííèõ àáñîëþòíûõ ññûëîê (URL)
urls - Àäðåñ ñàéòà ïðîåêòà HTTPS äëÿ íóæä ðåäèðåêòîâ è âíóòðåííèõ àáñîëþòíûõ ññûëîê (URL)
url_shtml - Êîíå÷íûé URL äî øàáëîíîâ SSI (ôàéëîâ shtml)
configloadstatus - Ñòàòóñ ÷òåíèÿ ôàéëà <prefix>.conf (0 - íå ïðî÷òåíî /1 - ïðî÷òåíî)
locked_keys - Ñïèñîê (ññûëêà íà ìàññèâ) çàùèùåííûõ êëþ÷åé êîíôèãóðàöèè
Ôëàãè (0 - âûêëþ÷åíî / 1 - âêëþ÷åíî):
_debug_ - Ôëàã îòëàäêè
_syslog_ - Ôëàã èñïîëüçîâàíèÿ ñèñòåìíîãî ëîãà â êà÷åñòâå ñòàíäàðòíîãî ëîãà îøèáîê è îòëàäêè
_sendmail_ - Ôëàã ðàçðåøåíèÿ îòïðàâêè e-mail
_errorsendmail_ - Ôëàã ðàçðåøåíèÿ îòïðàâêè e-mail ïî ôàêòó îøèáîê (exception)
Îñîáûå ïåðåìåííûå (extended). Ýòè ïåðåìåííûå ìîãóò áûòü îïðåäåëåíû â êîíôèãóðàöèîííîì ôàéëå âèðòóàëüíîãî õîñòà, èëè æå â ôàéëå êîíôèãóðàöèè ïðîåêòà fileconf (íàïðèìåð, <prefix>.conf)
content_type - MIME òèï ñîäåðæèìîãî, Content-Type ïî óìîë÷àíèþ
smtp_host - IP àäðåñ èëè äîìåííîå èìÿ SMTP ñåðâåðà
smtp_user - Ëîãèí (åñëè òðåáóåòñÿ àâòîðèçàöèÿ SMTP)
smtp_password - Ïàðîëü (åñëè òðåáóåòñÿ àâòîðèçàöèÿ SMTP)
db_driver - Èìÿ äðàéâåðà, íàïðèìåð: CSV, DBM, ExampleP, File, Gofer, ODBC, Oracle,
Pg, Proxy, SQLite, Sponge, mysql
db_dsn - DSN ñîåäèíåíèÿ, íàïðèìåð: DBI:Oracle:MYSID
db_host - IP àäðåñ èëè äîìåííîå èìÿ áàçû äàííûõ
db_name - Èìÿ áàçû äàííûõ (èëè SID)
db_port - Ïîðò ÁÄ, åñëè îí íå ñòàíäàðòíûé
db_user - Ëîãèí ïîëüçîâàòåëÿ áàçû äàííûõ
db_password - Ïàðîëü ïîëüçîâàòåëÿ áàçû äàííûõ
db_timeout_connect - Âðåìÿ, â ñåêóíäàõ, îïðåäåëÿþùåå òàéìàóò íà ñîåäèíåíèå
db_timeout_request - Âðåìÿ, â ñåêóíäàõ, îïðåäåëÿþùåå òàéìàóò íà çàïðîñ
db_mysql_host - IP àäðåñ èëè äîìåííîå èìÿ áàçû äàííûõ MySQL
db_mysql_name - Èìÿ áàçû äàííûõ MySQL
db_mysql_user - Ëîãèí ïîëüçîâàòåëÿ áàçû äàííûõ MySQL
db_mysql_password - Ïàðîëü ïîëüçîâàòåëÿ áàçû äàííûõ MySQL
db_oracle_host - IP àäðåñ èëè äîìåííîå èìÿ áàçû äàííûõ Oracle
db_oracle_name - Èìÿ áàçû äàííûõ Oracle
db_oracle_user - Ëîãèí ïîëüçîâàòåëÿ áàçû äàííûõ Oracle
db_oracle_password - Ïàðîëü ïîëüçîâàòåëÿ áàçû äàííûõ Oracle
MSO CONFIGURATION (MULTISTORE)
Äëÿ êîíôèãóðèðîâàíèÿ MultiStore ñîåäèíåíèé, èñïîëüçóåòñÿ êîíñòðóêöèÿ â ôàéëå êîíôèãóðàöèè fileconf èìåþùàÿ âèä, ïðèìåðíî ñëåäóþùèé:
<store foo>
dsn DBI:mysql:database=TEST;host=192.168.1.1
user login
pass password
<Attr>
mysql_enable_utf8 1
RaiseError 0
PrintError 0
</Attr>
</store>
<store bar>
dsn DBI:Oracle:FOOSID
user login
pass password
<Attr>
RaiseError 0
PrintError 0
</Attr>
</store>
<store baz>
dsn DBI:Oracle:BARSID
user login
pass password
<Attr>
RaiseError 0
PrintError 0
</Attr>
</store>
Äàííûé ïðèìåð ìîæåò ðàñïîëàãàòüñÿ êàê â ôàëå êîíôèãóðàöèè fileconf òàê è â ëþáîì äðóãîì çàâèñèìîì ôàéëå, íàïðèìåð, conf/mso.conf
Ìåòîäû äîñòóïà ê ýòèì äàííûì êîíôèãóðàöèè ïðèâåäåíû íà ñòðàíèöå îïèñàíèÿ "EXAMPLE" in MPMinus::Store::MultiStore
API: INTERFACE AND METHODS
Îñíîâíîé ïðèíöèï MPMinus - ïðåäîñòàâëåíèå API! Èìåííî API ïîçâîëÿåò ìîäèôèöèðîâàòü êîä MPMinus íåçàâèñèìî îò êîäà Âàøèõ ïðîåêòîâ.
Âçàèìîäåéñòâèå ñ API âûïîëíÿåòñÿ â äâà ýòàïà. Ïåðâûé - ìîìåíò êîìïèëëÿöèè; âòîðîé - ìîìåíò âûïîëíåíèÿ. Íà ìîìåíò êîìïèëëÿöèè ïðîèñõîäèò îáúåäèíåíèå âñåõ âàùèõ êëàññîâ ñ êëàññàìè ÿäðà MPMinus. Íà ìîìåíò âûïîëíåíèÿ âûçûâàþòñÿ òå èëè èíûå ìåòîäû MPMinus.
Âñå ìåòîäû MPMinus óñëîâíî äåëÿòñÿ íà 2 êëàññà: îñíîâíûå ìåòîäû è óòèëèòàðíûå ìåòîäû.
MAIN METHODS MPMinus
Îñíîâíûå ìåòîäû MPMinus ïîçâîëÿþò ïîëó÷èòü äîñòóï ê îñíîâíûì èíñòðóìåíòàì ÿäðà MPMinus - ïîäêëþ÷åííûì îáúåêòàì ÿäðà MPMinus.
- m, glob
-
See MPMinus
- r, req
-
See MPMinus
- drec, drecord, record
-
See MPMinus
- set, set_node
-
See MPMinus
- get, get_node
-
See MPMinus
- conf, config, get_conf, get_config
-
See MPMinus
- set_conf, set_config
-
See MPMinus
- mysql, oracle, multistore
-
See MPMinus
- disp, dispatcher
-
See MPMinus
- namespace
-
See MPMinus
UTILYTARY METHODS MPMinus KERNEL'S
Óòèëèòàðííûå ìåòîäû ïðèçâàíû îáåñïå÷èòü äîñòóï ê ìåõàíèçìàì ëîãèðîâàíèÿ, îòëàäêè, îòïðàâêè ïèñåì, îáðàáîòêè èñêëþ÷åíèé è ò.ï.
- log( $message, $level, $file, $sep )
-
Ëîãèðîâàíèå òåêñòà $message ñ óðîâíåì êðèòè÷íîñòè $level â ôàéë $file è ðàçäåëèòåëåì çíà÷åíèé $sep
$message - ñîîáùåíèå.
$level - Óðîâåíü êðèòè÷íîñòè çàïèñè ëîãà (ñì. ïðîöåäóðó syslog())
$file - ÀÁÑÎËÞÒÍÛÉ ïóòü è èìÿ ôàéëà êóäà ïèñàòü. Ïî óìîë÷àíèþ èñïîëüçóåòñÿ ôàéë default.log TEMP-äèðåêòîðèè
$sep - Ðàçäåëèòåëü çíà÷åíèé. Ïî óìîë÷àíèþ ïðîáåë
Ôëàã _syslog_ ïåðåêëþ÷àåò âûâîä èç óêàçàííîãî ôàëà â ñèñòåìíûé ëîã, áåç ñîçäàíèå ïåðâîãî
Áîëåå ïîäðîáíóþ èíôîðìàöèþ ñì. "DESCRIPTION" in MPMinus::Util
- syslog( $message, $level )
-
Ïðîöåäóðà èñïîëüçóåò ôóíêöèþ àïà÷à äëÿ âñòàâêè çàïèñåé â ñèñòåìíûé ëîã
$message - ñîîáùåíèå.
$level - Óðîâåíü êðèòè÷íîñòè çàïèñè ëîãà (â ïîðÿäêå óâåëè÷åíèÿ êðèòè÷íîñòè: info, debug, notice, warn, error, crit, alert, emerg)
Áîëåå ïîäðîáíóþ èíôîðìàöèþ ñì. "DESCRIPTION" in MPMinus::Util
- debug()
-
Çàïèñü â ëîã ñîîáùåíèÿ ñ óðîâíåì êðèòè÷íîñòè debug. Ñíÿòûé ôëàã _debug_ îòêëþ÷àåò ýòîò ìåõàíèçì.
$message - ñîîáùåíèå
$debug - ôëàã ñèñòåìíîé èíôîðìàöèè. 1 - âêëþ÷èòü äîáàâëåíèå ñèñòåìíîé èíôîðìàöèè / 0 - âûêë
$filename - ÈÌß ôàéëà äëÿ îòëàäêè. Ïî óìîë÷àíèþ êîíôèãóðàöèîííîå çíà÷åíèå file_debug
- sendmail( ... ), send_mail( ... )
-
Sending mail
- exception( $err )
-
Îïåðàöèÿ âûâîäà â ëîã ñîîáùåíèÿ $err ñ óðîâíåì exception.
Åñëè â ñîîáùåíèè $err óêàçàíà ïîäñòðîêà "[SENDMAIL]" è âîçâåäåí ôëàã _errorsendmail_ òî ïðîèçîéäåò îòïðàâêà óâåäîìëåíèÿ íà e-mail.
Áîëåå ïîäðîáíóþ èíôîðìàöèþ ñì. "DESCRIPTION" in MPMinus::Util
HANDLERS
!!! Òóò îïèñûâàåì õýíäëåðû, ïðèíöèï ïîñòðîåíèÿ êëàññà !!!
HANDLER'S TYPES
!!! Òèïû !!! ñì. ñîîòâ. ñåêöèþ êîíôèãóðàöèè mod_perl2 !!!
òèï õýíäëåðà modperl âìåñòî ñòàíäàðòíîãî (perl-script)
Åñëè èñïîëüçóåòñÿ $r->handler('modperl') òî íóæíî óñòàíàâëèâàòü îïöèè:
PerlOptions +GlobalRequest
PerlOptions +SetupEnv
Ïîäðîáíåå ñì. http://perl.apache.org/docs/2.0/user/config/config.html#C_SetHandler_
FILTERS
!!! Òóò îïèñûâàåì ôèëüòðû !!!
sub handler {
...
$r->add_output_filter(\&OutputFilterHandler); # Óñòàíàâëèâàåì õýíäëåð OutputFilter
$r->add_input_filter(\&InputFilterHandler); # Óñòàíàâëèâàåì õýíäëåð InputFilter
...
}
MVC
Øàáëîí ïðîåêòèðîâàíèÿ MVC êàê ÷àñòíûé ñëó÷àé â ïðàêòèêå ðàçðàáîòêè WEB ïïðèëîæåíèé ìîæíî îïèñàòü òðèàäîé.
- Model
-
×òåíèå è èçìåíåíèå íåïîñðåäñòâåííî äàííûõ. Ïðåäîñòàâëÿåòñÿ ïîñðåäñòâîì èñïîëüçîâàíèÿ DBI, SOAP, LDAP...
- View
-
Ïðåäîñòàâëåíèå äàííûõ ïîëüçîâàòåëþ. TemplateM, Template Toolkit, Mason, HTML::Template...
- Controller
-
Êîíòðîëü âñåãî ýòàïà çàïðîñà, ïðîâåðêà ïàðàìåòðîâ, äèñïåò÷åðèçàöèÿ äåéñòâèé, óïðàâëåíèå ïîòîêîì.  ýòîì çàêëþ÷àåòñÿ âåñü MPMinus.
Áîëåå ïîäðîáíóþ èíôîðìàöèþ î MVC, à âåðíåå ñêàçàòü øàáëîíà ïðîåêòèðîâàíèÿ, ÷èòàéòå â ñîîòâåòñòâóþùåé äîêóìåíòàöèè. Çäåñü æå ñëåäóåò ðàññêçàòü î äâóõ ïîäõîäàõ - êëàññè÷åñêîì MVC è î ïîäõîäå "MVC SKEL".
CLASSIC MVC
!!! Òóò îïèñûâàåì ñòàíäàðòûíé ìåõàíèçì çàïðîñ - îòâåò íà ïðèìåðå pay.allo èëè kernel !!!
MVC SKEL
!!! Òóò îïèñûâàåì Transaction ìîäåëü íà ïðèìåðå AAA èëè àíàëîãà òèïà Root !!!
MODEL
Ìîäåëüþ ìîæåò áûòü ëþáàÿ áàçà äàííûõ, ëþáîå óñòðîéñòâî, õðàíèëèùå è ò.ï. Èçíà÷àëüíî MPMinus áûë àäàïòèðîâàí äëÿ ðàáîòû ñ MySQL. Ïîçæå MPMinus íàó÷èëñÿ ðàáîòàòü ñ Oracle, íó è íàêîíåö MPMinus ïîëó÷èë âîçìîæíîñòü ðàáîòàòü ñ ëþáîé DBI-ñîâìåñòèìîé ÁÄ.
!!! òóò îïèñûâåì îáùèé ïðèíöèï ðàáîòû ñ íîäàìè ÁÄ !!!
MySQL
!!! MySQL !!!
use MPMinus::Store::MySQL;
...
sub handler {
...
$m->set_node(
mysql => new MPMinus::Store::MySQL (-m => $m, -attributes => {mysql_enable_utf8 => 1})
) unless ($m->mysql);
...
}
Oracle
!!! Oracle !!!
MultiStore
!!! MultiStore !!!
!!! ïèñàòü ïðèìåðû ðàáîòû ñ ïàðàìåòðàìè ÁÄ ïî ÷àñòè íàñòðîéêè è ïðèìåðû èñïîëüçîâàíèÿ
áàçû äàííûõ, à òàêæå ìåõàíèçì êîíôèãóðèðîâàíèÿ msconfig. Íàïèñàòü ðàöèîíàëüíîñòü
èñïîëüçîâàíèÿ multistore êîííåêòîâ !!!
THANKS
Thanks to Dmitry Klimov for technical translating http://fla-master.com
.
AUTHOR
Serz Minus (Lepenkov Sergey) http://serzik.ru <minus@mail333.com>
COPYRIGHT
Copyright (C) 1998-2013 D&D Corporation. All Rights Reserved
LICENSE
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See LICENSE
file
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 19:
Non-ASCII character seen before =encoding in 'WEB-ñåðâåð'. Assuming CP1252