Table Of Content

Introduction
Server Platform
Application Server
Content Generation
Kernel And API
   Runtime System
   Process
   DataBase
   WebServer
   UserData
   Context
   Page
   Elements
   Templates
   Menu
   CGI
   Form
   Table
   DirectoryTree
   Application
Manual Index
Keyword Search

Next Page | Previous Page

Maxscape Library

The Maxscape kernel implements the generic functionality for dynamic content generation out of a database and the file system. The Maxscape API gives access to context, documents, templates, elements and other data in an object oriented way. Thus, the power of SQL, Perl and the document languages could easily be combined.

At the moment the Maxscape library comprises approximately 80 packages with more than 1400 member functions. Because application specific scripts are stored in the content database also, it is not that easy to tell the exact number of source lines. All in all, Maxscape has about 480000 lines of Perl source code, SQL statements, Shell and Perl scripts, makefiles, a.s.o., the Basic Server Platform counts extra.

The Library contains many internal functions, which you possibly will never need to touch upon. Examples are functions of the Maxscape::Process package.

package Maxscape::Process; # exemplary code

sub execute {
  my ($Process) = shift;
  my ($Request, $ClientConnection) = @_;

  my $Response = Maxscape::HTTP::Response->new();

  my ($Context, $UserData) = $Process->acceptRequest ($Request, $ClientConnection);

  $Context->lookupPage ($Response);

  my $Page = Maxscape::Page->new (Context  => $Context,
                                  Response => $Response,
                                  Request => $Request,);
                       
  $Response->{Content} = $Page->Document();

  return $Response;
}

Many of the $Page object's methods are for use in appliction scripts. As you can see, all details like SQL queries, are hidden and handled by the $Page object:

#  Get the CGI variable 'ElementName' and
#  fetch the corresponding element from the content database.

sub myFunctionOrMethod {
  my ($Page) = shift;

  my $ElementName = $Page->CGI->Query('ElementName');
  ...
  my $Text = $Page->ElementContent ( Name => $ElementName, Type => 'parsed' );
  ...
  return $Text;
}

Maxscape Application Prorgraming Interface

Mainly four techniques are used, to include server and application programs into the content database and the application server.

Embedding variables and function calls in text elements
Text elements of type 'parsed' may contain embedded variables, method and function calls. The generation algorithm then takes care to evaluate them in the right context.
Elements that contain Perl scripts.
Database elements of type 'execute' may contain Perl scripts to generate the element's content.

Defining page, element, template and other callbacks
A callback mechanism is offered, to define page, element and template callbacks.

Using packages via various plug-in interfaces
Packages could be plugged in via the application plug-in mechanism at several levels (site global, application server, process).

Invoking functions in Database Elements and Templates

There are several ways to call application functions within the page generation process. One possibility to mix a document description language (e.g. XML) with function calls, is via PERL closures embedded in the text. The closures may contain server API methods, as well as application functions, included via the plugin mechanisim.

...
@{[$::WebServer->TimeAsString()]}
...

As you see from the example, HTML code and the closure can
freely be mixed. The output of the example is:

2021-01-20 04:06:16

Writing Application Functions around the '$Page' Object

To access the '$Page' object defined by the runtime system within applications, functions must have the following form:

sub myFunction {
  my ($Page) = @_;

  my $Text;

  #e.g. my $Text .= $Page->ElementContent('Title');
  ...
  return $Text;
}

The '$Page' parameter, taken by the function, is the actual pages '$Page' object, which contains several other objects (CGI, Context, UserData, ...), as members. Thus, the '$Page' object must be passed, when the function is called within an element.

You may also explicitly define your method to be in the 'maXscape::Page' package by issuing a package statement in your application file. This way the application function behaves like a method of the '$Page' object.


package maXscape::Page;

sub myPageMemberFunction {
  my ($self) = @_;
  ...
  return $Text;
}

To call this function, you can say:

my $Text = $Page->myPageMemberFunction( ... );

An application function must not use any print or STDOUT write functions to generate content. Instead, the content should be assigned to a variable, which is then returned by the function.

Page Member Function Call Example

This example shows, how to call a 'maXscape::Page' class method:

...
@{[ $Page->ElementContent ( Name => 'Title' ) ]}
...

The output is the title of this page: Maxscape Server API and Library


Next Page Previous Page Page Top Become a Member Contact Maxscape