Web-Development with OpenACS

Web-Development with OpenACS



AOLserver Background


    
    
    
    

AOLserver Basics


AOLserver is a full featured, multithreaded web application development environment for Unix. In addition to static page serving and CGI’s, AOLserver includes a rich and flexible C API for ... and many more
    
    
    
    

AOLserver TCL


The most useful ingredient to AOLserver is its native TCL integration lets have a look
    
    
    
    

AOLserver: CGI-style Prozedures


By definition, AOLserver API TCL commands start with ns_.
ns_register_proc maps a TCL procedure to an URL.


ns_register_proc GET /demo/time getTime

proc getTime {} {
  set headers [ns_conn headers]
  set browser [ns_set iget \$headers User-Agent]
  set page < html> < body>
  append page "Time: [clock seconds]
" append page "Browser: $browser" append page "< body>< /html>" ns_return 200 text/html $page }
    
    
    
    

AOLserver commands


By convention all commands from the AOLserver TCL API start with ns_: Though the native API is pretty good, OpenACS introduces a capsulating API for nearly all of the native API with many benefits. More later.
    
    
    
    

AOLserver TCL vs. ADP pages


AOLserver knows two primary types of pages, which can contain TCL code as well as a Library for TCL procedures.
    
    
    
    

AOLserver multithreaded TCL


While AOLserver provides a powerful Tcl interface, what is really interesting is AOLservers use of multithreaded Tcl If you are interested in a more detailed look:
Tcl in AOL Digital City: The Architecture of a Multithreaded High-Performance Web Site.
    
    
    
    

OpenACS (History)


    
    
    
    

OpenACS structure


In contrast to previous versions of ACS, OpenACS uses a three-tier architecture for delivering websites
    
    
    
    

OpenACS DB API


improved api, which handles among others. Some often used commands:
    
    
    
    

OpenACS Request Processor


The 4.5 Request Processor is a global filter and set of Tcl procs that respond to every incoming URL reaching the server. The URL is processed in four stages Good news: Most of the time you wont have to deal with the request processor as it is handling all of this automatically. For more information on the request processor look at
http://openacs.org/doc/openacs-4/request-processor.html
    
    
    
    

OpenACS Packages


Packages are a collection of files for for a single service or module. The APM (ACS Package Manager) helps you by: For more information have a look at
http://openacs.org/doc/openacs-4/packages.html
    
    
    
    

OpenACS Objects


Objects are anything represented in the application's data model that will need to be managed by any central service in OpenACS 4.5, or that may be reusable in the context of future applications. It helps you with For more information have a lookt at
http://openacs.org/doc/openacs-4/objects.html
    
    
    
    

OpenACS Permission System


The OpenACS 4.5 Permissions system allows developers and administrators to set access control policies at the object level. For easier maintenance But how do we use this in our application?
# main index page for notes.

ad_page_contract {
   @author you
   @cvs-id $Id: permissions.html,v 1.7.2.1 2002/05/15 23:26:18 vinodk Exp $
} -properties {
  notes:multirow
  context_bar:onevalue
  create_p:onevalue
}

set package_id [ad_conn package_id]
set user_id [ad_conn user_id]

set context_bar [ad_context_bar]
set create_p [ad_permission_p $package_id create]

db_multirow notes notes {
  select note_id, owner_id, title, body,
         decode(acs_permission.permission_p(note_id,
                                            :user_id,
                                            'write'),
                't', 1,
                'f', 0) as write_p,
         decode(acs_permission.permission_p(note_id,
                                            :user_id,
                                            'admin'),
                't', 1,
                'f', 0) as admin_p,
         decode(acs_permission.permission_p(note_id,
                                            :user_id,
                                            'delete'),
                't', 1,
                'f', 0) as delete_p
  from notes n, acs_objects o
  where n.note_id = o.object_id
  and o.context_id = :package_id
  and acs_permission.permission_p(note_id, :user_id, 'read') = 't'
  order by creation_date
}

ad_return_template

And respondingly in the .adp page:

if <@notes.write_p@ eq 1>
  < a href=add-edit?note_id=@notes.note_id@>@notes.title@< /a>
< /if>
< else<
  @notes.title@
< /else>

    
    
    
    

Sample Tour of Webservices


Let us have a quick look at some of the functionalities