*httpd.community* is a decendent of [httpd.taourl](wiki?taourl). It adds an sqlite based user, group, and access control system. It is implemented in [community.tcl](finfo?name=modules/community/community.tcl).
## Required Packages
Community relies on the following external packages:
* sha1 from [tcllib](http://core.tcl.tk/tcllib)
* sqlite3 from [sqlite](http://www.sqlite.org)
Community uses the following internal packages:
* tao from [tao](../tao/tao.md)
* tao-sqlite [tao-sqlite](../tao-sqlite/tao-sqlite.md)
## Options
* dbfile - Path to a file which stores the sqlite database for the community (default in-memory)
* virtual - Root Url of this object.
## Attached Objects
Community objects (and their derived classes) contain an embedded sqlite
database. This database can be accessed via that \<db\> method.
## Methods

*httpd.community* is a decendent of . It adds an sqlite based user, group, and access control system. It is implemented in [community.tcl](finfo?name=modules/community/community.tcl).
## Ancestors* [httpd.taourl](../directoo/taourl.md)* [yggdrasil](../tao-sqlite/yggdrasil.md)
## Required Packages
Community relies on the following external packages:
* sha1 from [tcllib](http://core.tcl.tk/tcllib)
* sqlite3 from [sqlite](http://www.sqlite.org)
Community uses the following internal packages:
* tao from [tao](../tao/tao.md)
* tao-sqlite [tao-sqlite](../tao-sqlite/tao-sqlite.md)
## Properties* create\_sql - An SQL script that implements the schema
## Options
* dbfile - Path to a file which stores the sqlite database for the community (default in-memory)
* virtual - Root Url of this object.
## Attached Objects
Community objects (and their derived classes) contain an embedded sqlite
database. This database can be accessed via that \<db\> method.
## Methods
### method Database\_FunctionsAdds the following functions to the database:* uuid\_generate() - Generates sha1 UUIDs on demand* sha1() - Returns the SHA1 hash of the input### accessTypesReturns a list of all possible rights.### aclRights *aclname* *user\_or\_group\_id*Return a list of rights that the user or group to the access control list (specified by name.)### method httpdSessionLoad *sock* *prefix* *suffix*This method looks for a sessionid cookie or a sessionid field in the GET or POST query, andpairs it with a session in the *session* table. If no session is found, a new session is generatedfor an anonymous user.### method httpdSessionSave *sock*This method compares the current value of **result\(session\)** to **result\(session\_delta\)** (a copyof the session when the pageview began. Fields that are in the delta, but not in the current session are deletefrom **session\_property**. Fields that are present in the session but not the delta are inserted into**session\_property**. Fields present in both, but with a different value, are updated.The server will generate a cookie called **sessionid** which will be loaded on the next page view.

* code - HTTP code to return (default 400)
* body - The block of data to be sent via *Httpd_ReturnData* or *Httpd_ReturnCacheableData* at the conclusion of the operation.
* content-type - The type of content in *block* (default text/html)
## Methods
### configurelist *keyvaluelist*
Pass configuration items as a key/value list.
### cget *field*
Retrieve the value of a configuration item
### /html
A method which implements the default root page of the object.
### initialize
A method which is called in the constructor, after the configuration items have been applied and the domain registered with Tclhttpd.
### httpdDirect *sock* *suffix*
This method is the first called when resolving a dynamic page. It calles *httpdSessionLoad* to load the session, *httpdMarshalArguments* do compute the method to call. On error, this method returns an error message. On success it calls *httpdSessionSave*, before sending the resulting data out to TclHttpd via the *Httpd_ReturnData* or *Httpd_ReturnCacheableData* procs.
### httpdMarshalArguments *sock* *suffix*
Calculate the command which will implement the current page view.
### httpdSessionLoad *sock *prefix* *suffix*
Initializes the *result* variable, and load session data from either cookies or the incoming GET/POST query. This method also calls the *Cgi_SetEnv* and *Url_QuerySetup* procs from Tclhttpd. Rather than populate the global *env* variable, Cgi_SetEnv populates the private *env* variable for this object.
### httpdSessionSave *sock*
Updates the current session, and writes cookies back to the browser.
### reset
Reset the current value of result(body)
### puts
Append to the value of result(body). Accepts multiple arguments. An implied \n is appended at the tail end.
### unknown *args*
Handler for unknown, incomplete, or invalid queries.

* code - HTTP code to return (default 400)
* body - The block of data to be sent via *Httpd_ReturnData* or *Httpd_ReturnCacheableData* at the conclusion of the operation.
* content-type - The type of content in *block* (default text/html)
## Methods
### method configurelist *keyvaluelist*
Pass configuration items as a key/value list.
### method cget *field*
Retrieve the value of a configuration item
### /html
A method which implements the default root page of the object.
### method initialize
A method which is called in the constructor, after the configuration items have been applied and the domain registered with Tclhttpd.
### method httpdCookieSet *field* *value* *?expire?*Set a cookie named *field* and value of *value*. If *expire* is a postitive integer,it indicates how long (in seconds) this cookie should last.Note: Cookies destined for "localhost" are mapped to null sobrowser will honor them properly.### method httpdHostNameReturn the host name by which this page was accessed. Derivedfrom env\(HTTP\_HOST\).
### method httpdDirect *sock* *suffix*
This method is the first called when resolving a dynamic page. It calles *httpdSessionLoad* to load the session, *httpdMarshalArguments* do compute the method to call. On error, this method returns an error message. On success it calls *httpdSessionSave*, before sending the resulting data out to TclHttpd via the *Httpd_ReturnData* or *Httpd_ReturnCacheableData* procs.
### method httpdMarshalArguments *sock* *suffix*
Calculate the command which will implement the current page view.
### method httpdSessionLoad *sock *prefix* *suffix*
Initializes the *result* variable, and load session data from either cookies or the incoming GET/POST query. This method also calls the *Cgi_SetEnv* and *Url_QuerySetup* procs from Tclhttpd. Rather than populate the global *env* variable, Cgi_SetEnv populates the private *env* variable for this object.
### method httpdSessionSave *sock*
Updates the current session, and writes cookies back to the browser.
### method reset
Reset the current value of result(body)
### method puts
Append to the value of result(body). Accepts multiple arguments. An implied \n is appended at the tail end.
### method unknown *args*
Handler for unknown, incomplete, or invalid queries.

Changes to modules/directoo/directoo.tcl.

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

oo::class create httpd.meta {
destructor {
catch {::Url_PrefixRemove [my cget virtual]}
}
method initialize {} {}
# This calls out to the Tcl procedure named "$prefix$suffix",
# with arguments taken from the form parameters.
# Example:
# httpdDirect /device Device
# if the URL is /device/a/b/c, then the Tcl command to handle it
# should be
# [self] /html/Device/a/b/c