Codebase list libcgi-xmlapplication-perl / 7969dd3
Imported Upstream version 1.1.4 Lucas Kanashiro 8 years ago
5 changed file(s) with 155 addition(s) and 77 deletion(s). Raw diff Collapse all Expand all
1818 examples/minimalapp.pm
1919 examples/minimal.xsl
2020
21 META.yml Module YAML meta-data (added by MakeMaker)
22 META.json Module JSON meta-data (added by MakeMaker)
0 {
1 "abstract" : "unknown",
2 "author" : [
3 "unknown"
4 ],
5 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380",
7 "license" : [
8 "unknown"
9 ],
10 "meta-spec" : {
11 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : "2"
13 },
14 "name" : "CGI-XMLApplication",
15 "no_index" : {
16 "directory" : [
17 "t",
18 "inc"
19 ]
20 },
21 "prereqs" : {
22 "build" : {
23 "requires" : {
24 "ExtUtils::MakeMaker" : "0"
25 }
26 },
27 "configure" : {
28 "requires" : {
29 "ExtUtils::MakeMaker" : "0"
30 }
31 },
32 "runtime" : {
33 "requires" : {
34 "XML::LibXML" : "1.1",
35 "XML::LibXSLT" : "1.08"
36 }
37 }
38 },
39 "release_status" : "stable",
40 "version" : "v1.1.4"
41 }
0 ---
1 abstract: unknown
2 author:
3 - unknown
4 build_requires:
5 ExtUtils::MakeMaker: 0
6 configure_requires:
7 ExtUtils::MakeMaker: 0
8 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380'
10 license: unknown
11 meta-spec:
12 url: http://module-build.sourceforge.net/META-spec-v1.4.html
13 version: 1.4
14 name: CGI-XMLApplication
15 no_index:
16 directory:
17 - t
18 - inc
19 requires:
20 XML::LibXML: 1.1
21 XML::LibXSLT: 1.08
22 version: v1.1.4
11
22 How To Install?
33
4 The installation should be perlish :)
4 The installation should be perlish
55
66 perl Makefile.PL
7 make
7 make
88 make test
99 make install
1010
1414 What is CGI::XMLApplication?
1515
1616 Perl modules to implement OO CGI-Scripts with XML capabilities in
17 Perl similar to CGI::Application. It is not related to CGI::XML
18 (than it would be CGI::XML::Application) ;) and does not include
19 any features of it (yet)
17 Perl similar to CGI::Application. It is not related to CGI::XML
18 (than it would be CGI::XML::Application) and does share its features.
2019
21 CGI::XMLApplication is not a simple add on to CGI.pm! I think there
20 CGI::XMLApplication is not a simple addon to CGI.pm! I think there
2221 is no simple and fast way to convert existing CGI scripts. This is
2322 basicly because of the gap of main concepts and paradigmata between
2423 CGI.pm and CGI::XMLApplication, although CGI.pm is the SUPER class of
25 CGI::XMLApplication.
24 CGI::XMLApplication.
2625
27 Why is there broken english?
26 Why is there so much broken english?
2827
29 I don't need english for living, but I can speak "all right", but
30 writing is something different :)
31 I will try to fix the broken section as soon as possible, so I hope
32 this situation does not last a long time ;)
33
34 The problems behind the scene.
28 The original code and documentation has been writtin in 2003/4 and
29 the documentation shows my poor English back then.
30 If you find the documentation offending to the English language, please
31 nudge me via RT.cpan.org and ask me to improve a particular section. I
32 will see to it that I will improve the documentation. An even
33 better approach is to create a pull-request on github that corrects the language.
34
35 Behind the scene.
3536
3637 While most CGI-Scripts are embedded into larger web based applications
3738 the scripts themselves usually do not represent this fact. The
9596 I see, is that CGI::XMLApplication includes the XML paradigma of
9697 dispairing data and datapresentation.
9798
98 The second major difference is, that a perl programmer does not have
99 The second major difference is, that a perl programmer does not have
99100 that much freedom on the programm structure. Yes, CGI::XMLApplication
100 is rather strict compared to what perl is known for ;) I realized in
101 my day to day work, this freedom causes a lot of problems in midsize
102 or large W3 application projects.
101 is rather strict for perl standards. I realized in my daily work that
102 this freedom causes a lot of problems in midsize or large web-based
103 applications.
103104
104105 The less obvious difference is how the data presentation is
105106 done. While CGI::Application uses the "propritary" perl format for
106107 data presentation, CGI::XMLApplication uses by default XML and XSLT,
107 which are a web standard. This leaves the oportunity to change the
108 which are standardised. This leaves the oportunity to change the
108109 programm code and even the programming language, but leaves the data
109 presentation untouched. As well new output formats can be added,
110 without changeing the entire script code. This is what project
111 managers really like to hear ;)
110 model untouched. New output formats can be added without changing
111 the entire code.
112112
113 Classical CGI scripts will have most allways quite a lot print calls
113 Old-school CGI scripts will have most allways quite a lot print calls
114114 (or at least some thing similar). All these calls are related to the
115115 field of data persentation, usually a job done by designers or HTML
116 programmers. Both modules CGI.pm and CGI::Application include such --
117 what I call -- formating functions. A perl coder using
118 CGI::XMLApplication does not need to care about the data presentation
119 a client will finally see. Therefore formated output calls as they are
120 used in CGI.pm and CGI::Application doesn't make much sense with
121 CGI::XMLApplication. The data presentation itself is done through XSLT
122 Stylesheets. The script has to care only about the data, which should
123 be kept in a XML-DOM. So a script programmer provides a set of data to
124 a stylesheet and does not care about the output anymore (which is done
125 by the class btw.)
116 programmers. Both modules CGI.pm and CGI::Application include such
117 formating functions. A perl coder using CGI::XMLApplication does not
118 need to bother about the data a client will finally see. Therefore,
119 formated output calls as they are used in CGI.pm and CGI::Application
120 doesn't make much sense with CGI::XMLApplication. Presenting data is
121 handled via XSLT Stylesheets. The script has to care only about the
122 data, which should be kept in a XML-DOM. So a script programmer
123 can pass data to a stylesheet and does not care about the output
124 anymore.
126125
127 As well CGI::XMLApplication implements a more strict application
126 As well CGI::XMLApplication implements a stricter application
128127 structure, than CGI::Application. CGI::XMLApplication handles script
129128 initialization, functionality, cleanup and data output is strictly
130129 separated parts of the script.
131130
131 Code repository
132
133 I moved the code to GITHUB with Version 1.1.4. Please, make a pull request
134 if you suggest changes to the code or the documentation.
135
136 The code is available here:
137
138 https://github.com/phish108/CGI-XMLApplication
139
140 Contributors
141
142 CGI::XMLApplication includes contributions of the following developers.
143
144 * Michael Kröll
145 * Kip Hampton
146 * Gregor Herrmann
0 # $Id: XMLApplication.pm,v 1.19 2004/03/10 17:55:00 c102mk Exp $
1
20 package CGI::XMLApplication;
31
42 # ################################################################
5 # $Revision: 1.19 $
6 # $Author: c102mk $
73 #
8 # (c) 2001 Christian Glahn <christian.glahn@uibk.ac.at>
9 # All rights reserved.
4 # (c) 2001 Christian Glahn <phish@CPAN.org>
105 #
116 # This code is free software; you can redistribute it and/or
127 # modify it under the same terms as Perl itself.
3227
3328 # ################################################################
3429
35 $CGI::XMLApplication::VERSION = "1.1.3";
30 $CGI::XMLApplication::VERSION = "1.1.4";
3631
3732 # ################################################################
3833 # general configuration
483478 content deliverment.
484479
485480 As well CGI::XMLApplication is designed to support project management
486 on code level. The class allows to split web applications into several
481 on code level. The class allows splitting web applications into several
487482 simple parts. Through this most of the code stays simple and easy to
488483 maintain. Throughout the whole runtime of a script
489484 CGI::XMLApplication tries to keep the application stable. As well a
519514 or less redundant code. Since most CGI-scripts are waiting for
520515 B<events>, which is usually the code abstraction of a click of a
521516 submit button or an image, CGI::XMLApplication implements a simple
522 event system, that allows to keep event related code as separated as
523 possible.
524
525 Therefore final application class is not ment to have a constructor
517 event system, that keeps event related code separated from other events.
518
519 Therefore, a final application class is not meant to have a constructor
526520 anymore. All functionality should be encapsulated into implicit or
527521 explicit event handlers. Because of a lack in Perl's OO implementation
528522 the call of a superclass constructor before the current constructor
687681 to any kind of display type, there should be no need to override this
688682 function. One can pass a context hash or context object, to pass external
689683 or prefetched information to the application. This context will be
690 available and acessable in all events and most extra functions.
684 available and accessible in all events and most extra functions.
691685
692686 This function does all event and serialization related work. As well
693687 there is some validation done as well, so catched events, that are not
755749
756750 To make it clear: If CGI::XMLApplication throws a panic, the
757751 application is broken, not completely implemented or stylesheets are
758 missing or broken. Application panics are ment for debugging purposes
759 and to avoid I<Internal Server Errors>. They are B<not> ment as a
752 missing or broken. Application panics are meant for debugging purposes
753 and to avoid I<Internal Server Errors>. They are B<not> meant as a
760754 replacement of a propper error handling!
761755
762756 But how does CGI::XMLApplication know about the correct event handler?
776770
777771 Each event has a single Parameter, the context. This can be an unblessed
778772 hash reference or an object, where the user can store whatever needed.
779 This context is useful to pass scriptwide data between callbacks and
773 This context is useful to pass scriptwide data between callbacks and
780774 event functions around. The callback is even available and useable if
781775 the script does not initialize the application context as earlier shown
782776 in the program flow chart.
895889 =item event_default
896890
897891 This event is called as a fallback mechanism if CGI::XMLApplication
898 did not receive a stylesheet id by an other event handler; for example
899 if no event matched.
892 did not receive a stylesheet id by another event handler, for example
893 if no event is matched.
900894
901895 =back
902896
993987 or remove cookies. The keys of the hash must be the same as the named
994988 parameters of CGI.pm's header method. One does not need to care about
995989 the output of these headers, this is done by CGI::XMLApplication
996 automaticly.
990 automatically.
997991
998992 The content type of the returned data is usually not required to be
999993 set this way, since the XSLT processor knows about the content type,
1004998 If the B<getStylesheet> is implemented the CGI::XMLApplication will
1005999 assume the returned value either as a filename of a stylesheet or as a
10061000 XML DOM representation of the same. If Stylesheets are stored in a
1007 file accessable from the , one should set the common path for the
1008 stylesheets and let B<CGI::XMLApplication> do the parsing job.
1001 folder accessible for the the web-server, a common path for the
1002 stylesheets should be set and B<CGI::XMLApplication> will initiate
1003 the parsing job.
10091004
10101005 In cases the stylesheet is already present as a string (e.g. as a
10111006 result of a database query) one may pass this string directly to
10171012 If none of these stylesheet selectors succeeds the I<Stylesheet
10181013 missing> panic code is thrown. If the parsing of the stylesheet XML
10191014 fails I<Stylesheet not available> is thrown. The latter case will also
1020 give some informations where the stylesheet selection failed.
1015 provide details where the stylesheet selection failed.
10211016
10221017 B<selectStylesheet()> has to return a valid path/filename for the
10231018 stylesheet requested.
10241019
10251020 =item getXSLTParameter()
10261021
1027 This function allows to pass a set of parameters to XML::LibXSLT's xsl
1022 This function helps passing parameters to XML::LibXSLT's xsl
10281023 processor. The function needs only to return a hash and does not need
10291024 to encode the parameters.
10301025
10311026 The function is the last callback called before the XSLT processing is
1032 done.
1027 started.
10331028
10341029 =back
10351030
10361031 =head2 Flow Control
10371032
1038 Besides the sendEvent() function does CGI::XMLApplication provide to
1039 other functions that allow to controll the flow of the application.
1033 Besides the sendEvent() function, CGI::XMLApplication provides
1034 two additional functions for controlling the flow of the application.
10401035
10411036 These two functions are related to the XML serialization and have not
10421037 affect to the event handling.
10431038
10441039
1045 =over 4
1040 =over 4
10461041
10471042 =item passthru()
10481043
10641059 function should be used in set rather than get mode. The parameter is
10651060 interpreted as just described.
10661061
1067 If an application sets passthru by itself any external 'passthru'
1068 parameter will be lost. This is usefull if one likes to avoid, someone
1069 can fetch the plain (untransformed) XML Data.
1062 If an application sets passthru by itself, any external 'passthru'
1063 parameter will be lost. This is useful if the application requires
1064 access to the plain (untransformed) XML Data.
10701065
10711066
10721067 =item skipSerialization()
10951090 This function searches the query string for a parameter with the
10961091 passed name. The implementation is "imagesave" meaning there is no
10971092 change in the code needed, if you switch from input.type=submit to
1098 input.type=image or vv. The algorithm tests wheter a full name is
1093 input.type=image or vv. The algorithm tests whether a full name is
10991094 found in the querystring, if not it tries tests for the name expanded
11001095 by a '.x'. In context of events this function interprets each item
11011096 part in the query string list as an event. Because of that, the
11021097 algorithm returns only the first item matched.
11031098
1104 If you use the event interface on this function, make sure, the
1105 HTML-forms pass unique events to the script. This is neccessary to
1099 If you use the event interface with this function, then the
1100 HTML-forms should pass unique events to the script in order to
11061101 avoid confusing behaviour.
11071102
11081103 This function is used by testEvent() so if it is required to change
11121107
11131108 This a simple error message handler. By default this function will
11141109 print some information to the client where the application
1115 failed. While development this is a useful feature on production
1110 failed. During development, this is a useful feature, while on a production
11161111 system this may pass vunerable informations about the system to the
1117 outside. To change the default behaviour, one may write his own panic
1118 method or simply set I<$CGI::XMLApplication::Quiet> to 1. The latter
1119 still causes the error page but does not send any error message.
1112 clients. To change the default behaviour, I<$CGI::XMLApplication::Quiet>
1113 should get set to 1. This will still show an error page but without
1114 displaying error messages. Alternatively, the panic method can be overloaded.
11201115
11211116 The current implementation send the 404 status to the client if any
11221117 low level errors occour ( e.g. panic levels > -4 aka Application
11721167 =head2 some extra functions for stylesheet handling
11731168
11741169 The getStylesheet() function should return either a filename or a
1175 stringnyfied XSL-DOM. For the firstcase it can be a restriction to
1176 return the fully qualified path. The following functions allow to set
1177 the stylesheetpath systemwide.
1170 stringnyfied XSL-DOM. For the first case it can be a restriction to
1171 return the fully qualified path. The following functions help managing
1172 the stylesheetpath, system-wide.
11781173
11791174 =over 4
11801175
11861181
11871182 This method is for telling the application where the stylesheets can
11881183 be found. If you keep your stylesheets in the same directory as your
1189 script -- IMHO a bad idea -- you might leave this untouched.
1184 script you might leave this untouched. However, it is suggested to store
1185 stylesheet files in a directory that is out of reach for client access.
11901186
11911187 =item function getStylesheetPath
11921188
12021198
12031199 =head1 AUTHOR
12041200
1205 Christian Glahn, christian.glahn@uibk.ac.at
1201 Christian Glahn, phish@cpan.org
12061202
12071203 =head1 VERSION
12081204
1209 1.1.1
1205 1.1.4