Tcl Procs
- Use namespace
Define your procs with with a namespace like
mypackage::foo_proc
. Here is a discussion about this . Check many examples in the code, example:namespace eval auth {} ad_proc -public auth::require_login { {-level ok} {-account_status ok} } { doc... @return something @see ad_script_abort } { ... proc body }
- Use procs safely and their safer variations to help keep code robust and avoid security issues.
Particularly in cases, where user_input is processed, be sure to avoid executing unwanted code. Use the Tcl expand operator
{*}
instead ofeval
. Use
{*}$cmd
instead of
eval $cmd
For legacy code, you might use util::safe_eval instead of eval in such cases; subst_safe precedes meta characters with backslashes. - Use named parameters whenever possible
Define named parameters on your procs so parameters will not be mixed up if somebody makes a mistake on passing the order of parameters. Also this makes the proc easier to add additional parameters in the future if needed.
Use:
ad_proc proc_name { {-parent_id pid} {-child_id cid} } ...
and not
ad_proc proc_name {pid cid} ...
This way developers will need to call proc stating explicitly which parameter are passed. This is especially useful when some parameters are optional.
Also, when calling a proc in your tcl script, is recommended to write one parameter per line like this:
set my_var [proc_name \ -parent_id $pid \ -child_id $cid]
Rather than:
set my_var [proc_name -parent_id $pid -child_id cid]
Again, this helps to make the code more clean and readable.
- Use ad_proc to define your Tcl procs
Make use of ad_proc. And make use of the self documentation facility of ad_proc.
ad_proc foo {} Use this area to document } # .... your implementation of proc foo }
-
This way the API browser will pick up your documentation automatically. Is encouraged to use automatic api-doc documentation that ad_provides, such as:
@author
,@return
,@see
- Avoid using upvar
Try to avoid using upvar. If needed pass in a parameter that specifies the upvar name. This way the one using your proc has option to name his/her variable. Ex.
ad_proc upvaring {-upvar_name:required} { upvar $upvar_name local_var }
-
Use modern Tcl idioms
Do not use "
==
" in comparing strings. Using "if {$string == "foo"}
" tries to make a numeric comparison first. Instead make use of "if {"foo" eq $string}
" or if you need the negation "if {"foo" ne $string}
".
Do not use "if {[lsearch -exact $list $element] > -1}
", but use "if {$element in $list}
" instead, or "if {$element ni $list}
" in case a "not in" test is required. -
Always "Return" at the end of your proc
And if you have to return more than one variable, use associative arrays, which can be extended by additional fields without breaking code
So instead of this:
ad_proc ... { ..... return [list $creation_status $creation_message ...] }
use key/value pairs or Tcl arrays to group related information:ad_proc ... { array set creation_info { creation_status {} creation_message {} element_messages {} account_status {} account_message {} } ..... return [array get creation_info] }
- ... or even better: use Tcl dicts
ad_proc proc ... {} { set creation_info [dict create \ creation_status {} \ creation_message {} \ element_messages {} \ account_status {} \ account_message {} ] .... return $creation_info }
- Read the Tcl Style guide
This is the Tcl styleguide (PDF), try to apply relevant guidelines. In particular chapter 4,5 and 7
in last 30 minutes
OpenACS.org
- HOME
- News
- Community
- Getting admin-level help
- Getting help
- Goals / Ideas
- History of OpenACS
- Marketing Team
- Most Popular Pages
- OpenACS Translation server
- Events
- 2006 Fall Conference Interest in Attending
- 2006 Fall Conference Presentations
- 2006 Fall Conference Submissions and Program
- 2006 International Workshop on Community Based E-Learning Systems
- 2006 November 2nd (General Web Applications Focus - OpenACS)
- 2006 November 3rd and November 4th (Training and Hacking Days)
- 2006 OpenACS/.LRN Fall Conference
- 2006 Session 1: Towards full Accessibility in LMS
- 2007 Project Ideas for Google Summer of Code
- OCT
- Directory - Who's Who
- Documentation
- OpenACS Handbook
- for administrators
- for administrators - Table of Contents
- for beginning developers
- for developers
- for developers - Table of Contents
- for everyone
- for everyone - Table of Contents
- Collaboration Graph
- Documentation Credits
- Documentation History
- Documentation Introduction
- Documentation Process test-doc (Approach 3)
- Documentation Project Discussion
- Documentation Project Plan (Approach 4)
- Most Popular Pages
- Try Openacs
- WikiDoc Project Notice
- Core Documentation
- Subsystems Documentation
- for administrators
- for administrators - Table of Contents
- for beginning developers
- for developers
- for developers - Table of Contents
- for everyone
- for everyone - Table of Contents
- *nix operating system
- ::xo::db Object Relational Database Interface
- AOLserver
- AOLserver administration
- Administrators - Req.
- Available OpenACS Packages
- Boost your application performance to serve large files!
- Conditional CREATE Index for Postgresql and Oracle
- Deployment feedback channel
- Developer - Requirements
- Developer Tutorial - Req.
- Emacs as an OpenACS IDE
- End-users - Requirements
- Get the OpenACS Source Code
- Getting admin-level help
- Install AOLserver
- Install AOLserver 4.5
- Install OpenACS - prereqs
- Install OpenACS distribution
- Install OpenACS on Linux
- Install OpenACS on Mac OS X 10.5 / 10.6 (Snow Leopard) Using Macports
- Install OpenACS on debian unstable / Ubuntu 7.10
- Install OpenACS with NaviServer from Scratch
- Install Oracle
- Install Postgresql
- Install Tcl
- Install a *nix-based operating system (OS)
- Installation - Req.
- Installing OpenACS
- Installing OpenACS on Arch Linux
- Installing OpenACS on FreeBSD
- Installing OpenACS on FreeBSD (quick)
- Installing OpenACS on FreeBSD with ports
- Installing OpenACS on Mac OS X
- Installing OpenACS on RPM-based systems
- Installing OpenACS on Redhat
- Installing OpenACS on Solaris
- Installing OpenACS on SuSE
- Installing OpenACS on Windows
- Installing OpenACS on debian
- Installing OpenACS on win2k
- Mail Transport Agents
- Monitoring Naviserver
- Nagios Monitoring
- NaviServer
- Next Steps After Installation, Debian Specific
- OpenACS Debian Install quicksheet
- OpenACS Monitoring
- OpenACS Performance Tuning
- OpenACS Reference Platform
- OpenACS compatibility matrix
- OpenACS subsystem
- OpenACS system
- OpenACS/.LRN for Debian
- OpenACS/.LRN for Ubuntu
- OpenACS/dotLRN Windows Installer Instructions
- OpenACS/dotLRN windows installer how to
- Oracle
- Oracle Notes
- PostgreSQL
- PostgreSQL Administration
- PostgreSQL's Tsearch2
- Postgres 8.1.x to 9.1
- Securing your system
- Source control
- Tcl
- Tcl Thread Library
- Testing with Selenium
- Testing with TCLWebtest
- Upgrade between PostgreSQL versions
- Upgrade to OpenACS 5.8
- Upgrade to OpenACS 5.9
- Vi as an OpenACS IDE
- XOTcl
- hstore
- tDOM
- tDOM with OpenACS
- Package Documentation
- Aliases at CVS
- Available OpenACS Packages
- Packages available in the oacs-5-9 channel
- Documentation Non-Core Packages
- Marketing Documentation
- Tutorials
- for beginning developers
- Developer Tutorial - Req.
- Introduction to OpenACS
- Next Steps After Installation, Debian Specific
- OpenACS/dotLRN windows installer how to
- Theming in OpenACS
- Tutorials for Designers
- Tutorials for Users
- Tutorials for Administrators
- Tutorials for Programmers
- Add extra headers
- Automated Installs - Using install.xml
- Body Onload javascript event
- Emacs as an OpenACS IDE
- OpenACS 5.1.4 / PG 7.3.6 => 5.2.3/8.0.7 Upgrade Path for acs-core
- OpenACS mode for Emacs
- Vi as an OpenACS IDE
- Webinar - Part 1 - Basics
- Webinar - Part 2 - Site Map Administration
- Webinar - Part 3 - Packages and ad_form
- Webinar - Part 4 - Survey
- listbuilder tutorial
- Tutorials - The N00B Journey
- OpenACS Projects
- (Sketch for) OpenACS Home
- .LRN
- Activity Graph
- Admin Package RFC
- Bugtracker Cleanup Project
- Collaboration Graph
- Community Metrics in OpenACS
- Debian/Ubuntu installer developing
- Documentation Project
- Documentation Project Discussion
- Documentation Project Plan (Approach 4)
- Dynamic Object Types and Attributes
- E-Mail: Event Handling
- E-Mail: Incoming E-Mail
- E-Mail: Outgoing E-Mail
- Ecommerce G2
- Forums Project
- GETable resources, that should be POSTable resources
- Interface / CSS Coding Guidelines
- Logo
- Mentorship Program
- Migration from CVS to GIT
- Official Test Servers
- OpenACS 5.9 HTML validity fixes
- OpenACS Packaging for Debian and Ubuntu
- OpenACS Release Status
- OpenACS TODO List
- OpenACS/.LRN for Debian
- Package Object Types
- Package Testing Process
- Prerequisites and Procedures for Migrating to Subversion from CVS
- Site Nodes Proposal (Draft)
- Site Wide File Upload
- Site Wide Image Upload Widget
- Theme Manager
- Theming Project
- Translation server for OpenACS packages
- User interface mockups
- Website_Redesign
- XoWiki Design Ideas
- YUI Project
- {done} Change Log from OpenACS 5.4.2 to OpenACS 5.4.3
- {done} OpenACS 5.3.x releases
- {done} Release Notes OpenACS 5.4.3
- Marketing
- Our Website
- Packages
- Available OpenACS Packages
- Core Packages
- ACS API Browser
- ACS Admin
- ACS Authentication
- ACS Automated Testing
- ACS Bootstrap Installer
- ACS Content Repository
- ACS Core Docs
- ACS Default Theme
- ACS Developer Support
- ACS Kernel
- ACS Lang
- ACS Mail Lite
- ACS Messaging
- ACS Reference Data
- ACS Service Contract
- ACS Subsite
- ACS Tcl
- ACS Templating
- ACS Translations
- Intermedia Driver
- Notifications
- Reference Data - Country
- Reference Data - Language
- Reference Data - Timezone
- Search
- Tsearch2 Driver
- Non-Core Packages
- ACS Date Time
- ACS Events
- ACS Interface
- ACS Object Management
- Ad Server
- Address Book
- Ajax Filestore UI
- Ajax Helper
- Ajax Photoalbum UI
- Anonymous Evaluation
- Assessment
- Attachments
- Attendance
- Attribute Management System
- Auth CAS
- Auth HTTP
- Authentication Server
- Authorize.net Gateway
- B Responsive Theme
- Beehive
- Bookmarks
- Bookshelf
- Boomerang Plugin
- Bug tracker
- Bulk mail
- CMS
- CMS News Demo
- Calendar
- Calendar Includelet
- Cards
- Categories
- Chat
- Chat Includelet
- Clickthrough
- Clipboard
- Connections
- Contacts
- Content Includelet
- Cookie Consent Widget
- Cronjob
- Curriculum
- Curriculum Central
- Curriculum Tracker
- Datamanager
- Diagram
- Directory
- Download
- Dynamic Object Type
- E-Commerce
- EZIC Gateway
- Ecommerce Serial Number Tracking
- Edit This Page
- EduWiki
- Email Handler
- Evaluation
- Expense
- Expense Tracking
- FAQ
- Facebook API
- Feed parser
- File Manager
- File Storage Includelet
- File storage
- Forums
- Forums Includelet
- GateKeeper
- General comments
- Glossar
- Glossary
- IMS Enterprise
- Image Magick
- Imsld
- Invoices
- Jabber
- LAMS Integration
- LAMS Integration Configuration
- LDAP Authentication Driver
- LORS management Includelet
- Lab Report
- Lab Report Central
- Latest
- Layout Managed Subsite
- Layout Manager
- Learning Content
- Logger
- MMplayer
- Mail Tracking
- Monitoring
- New portal
- News
- News Includelet
- News aggregator
- Notes
- OCT Election
- Organization
- Outdated Library functions
- PAM Authentication Driver
- Package Builder
- Page
- Pages
- Payment Gateway
- Permissions Administrator
- Photo album
- Planner
- Poll
- Post Card
- Postal Address
- Press
- Profile provider
- Project Manager
- Q-Forms
- Q-Wiki
- Quota
- RSS support
- Ratings
- Recruiting
- Redirect
- Reference Data - Currency
- Reference Data - ITU Code
- Reference Data - UNSPSC code
- Reference Data - US County
- Reference Data - US State
- Reference Data - US Zipcode
- Related Items
- Richtext CKEditor 4
- Richtext CKEditor 5
- Richtext TinyMCE
- Richtext Xinha
- Robot Detection
- S5
- SOAP Gateway
- SOAP db
- Sample Gateway
- Schema Browser
- Scholarship Fund
- Scorm Core
- Scorm Importer
- Scorm Player
- Scorm Simple LMS
- Selva theme
- Shipping Service Contract
- Simple Survey
- Simulation
- Site-wide Search
- Skin
- Spreadsheet
- Static Pages
- Survey
- Survey Library
- Survey Reports
- T Account
- Tasks
- Tcl SOAP
- Telecom Information
- Trackback
- User preferences
- User profile
- Value-based Shipping
- Version Control
- Views
- WebDAV Support
- Weblogger
- Webmail System
- Wikipedia
- Wimpypoint slim
- Workflow
- XCMS User Interface
- XML RPC
- XO Learning Performance
- XOTcl Core
- XOTcl Request Monitor
- XoWiki
- XoWiki Includelet
- XoWiki Workflow
- dbm
- openacs-bootstrap3-theme
- xolirc
- xowf plugin for Monaco code editor
- ecommerce-g2
- Accounts Desk
- Accounts Finance
- Accounts Payables
- Accounts Payroll
- Accounts Receivables
- Bulk Upload
- CL Custom Commerce
- Customer Service
- E-commerce 2
- Fabrication
- Field Service
- General Ledger
- Human Resources
- Inventory Control
- Manufacturing Design
- Online Catalog
- Production
- Reference Data - GIFI
- Ship-Track
- Vendors-Suppliers
- DotLrn
- Anon Eval Applet
- Anon Eval Portlet
- Application track
- Application track Applet
- Application track portlet
- Assessment Applet
- Assessment portlet
- Attendance Applet
- Beehive Applet
- Beehive Portlet
- Bulk mail Applet
- Bulk mail Portlet
- Calendar Applet
- Calendar portlet
- Cards applet
- Cards portlet
- Chat Applet
- Chat Portlet
- Contacts Applet
- Contacts Portlet
- Content Applet
- Content Portlet
- Courses
- Curriculum Applet
- Curriculum Portlet
- Datamanager Portlet
- Edit-this-page Applet
- Edit-this-page Portlet
- EduWiki Applet
- EduWiki Portlet
- Evaluation applet
- Evaluation portlet
- Expense-tracking Applet
- FAQ Applet
- FAQ Portlet
- File Storage Applet
- File Storage Portlet
- Forums Applet
- Forums Portlet
- Glossar Applet
- Glossar Portlet
- Homework Applet
- IMS LD Portlet
- IMS-LD Applet
- Invoices Applet
- Invoices Portlet
- Jabber Applet
- Jabber Portlet
- LAMS Integration Applet
- LAMS Integration Portlet
- LORS - Learning Objects Repository Service
- LORS central
- LORS management
- LORS management Applet
- LORS management Portlet
- Latest Applet
- Latest Portlet
- Learning Content Applet
- Learning Content Portlet
- MMplayer Applet
- MMplayer Portlet
- Messages Applet
- Messages Portlet
- News Aggregator Applet
- News Aggregator Portlet
- News Applet
- News Portlet
- Photo Album Applet
- Photo Album Portlet
- Private-Message
- Project Manager Portlet
- Project-manager Applet
- Quota Applet
- Quota Portlet
- Random-photo Applet
- Random-photo Portlet
- Recruiting Applet
- Recruiting Portlet
- Research Applet
- Research Portlet
- Static Applet
- Static Portlet
- Survey Applet
- Survey Portlet
- Syllabus Applet
- Tasks Applet
- Tasks Portlet
- Theme Zen
- User Tracking
- User Tracking Applet
- User Tracking Portlet
- Weblogger Applet
- Weblogger Portlet
- Wikipedia Applet
- Wikipedia Portlet
- Wimpypoint Slim Applet
- Wimpypoint Slim Portlet
- XoWiki Applet
- XoWiki Portlet
- dotLRN
- dotLRN - Ecommerce
- dotLRN Administration
- dotLRN Bootstrap 3 Theme
- dotLRN Course Catalog
- dotLRN Datamanager Applet
- dotLRN Roadmap
- dotLRN applet
- dotLRN portlet
- Contrib Packages
- Acknowledgement
- BCDS
- BCMS
- BCMS UI Base
- BCMS UI Wizard
- COP Base
- COP UI
- Classified Ads
- Events Management
- Form To Mail
- IRC Logger
- Irc Applet
- Mail Clickthrough
- PayFlowPro Gateway
- Personal Community
- Photobook
- Populate
- Research Papers
- Resource List
- Room Reservation
- Users Selection
- Vocabulary
- mailing-lists
- Deprecated Packages
- {deprecated} ACS Content
- {deprecated} ACS LDAP Authentication
- {deprecated} ACS Mail
- {deprecated} ACS Utility Services
- {deprecated} Bboard Portlet
- {deprecated} OpenFTS Driver
- {deprecated} Portal
- {deprecated} Sloan Bboard
- {deprecated} Spam System
- {deprecated} Webmail
- {deprecated} Wiki
- {deprecated} Workflow Service
- {deprecated} dotFOLIO
- {deprecated} dotFOLIO UI
- {deprecated} dotLRN BBoard Applet
- F. A. Q.
- .LRN
- .LRN
- .LRN Accessibility
- .LRN Core Team (DRAFT)
- .LRN Educational standards support
- .LRN Get Involved!
- .LRN Governance
- .LRN Installation
- .LRN Installation (up to .LRN 2.5.0)
- .LRN Leadership Team 2008
- .LRN Meetings
- .LRN Motions (DRAFT)
- 2006 Fall Conference Submissions and Program
- Content development tools options
- Documentation and help pages for individual .LRN installations
- Educational Wiki (Eduwiki) Tool
- How to contribute code that passes accessibility tests
- Learning Content Tool
- Modelling Learners Preferences
- Plataforma Elearning
- SCORM support
- Simple Content Creator / Editor
- Time/Topics Planner for dotLRN Courses
- Consortium
- Releases
- .LRN 2.2 Release Management
- .LRN 2.2 bugs
- .LRN 2.2 to .LRN 2.3.0 Change Log
- .LRN 2.3 Release Management
- .LRN 2.3.0 to .LRN 2.3.1 Change Log
- .LRN 2.3.1 Release Notes
- .LRN 2.3.1 to .LRN 2.4 Change Log
- .LRN 2.4 Release Management
- .LRN 2.4 Release Notes
- .LRN 2.4.0 to .LRN 2.4.1 Change Log
- .LRN 2.4.1 Release Notes
- .LRN 2.5 Release Management
- Zen Project
- Coding Standards
- Coding Standards - Index
- .LRN Zen Project: Standards
- ADP Files
- Ajax and Accessibility
- Code Formatting
- Commit Messages
- Emacs as an OpenACS IDE
- How to contribute code that passes accessibility tests
- Logging Conventions
- Naming Conventions
- SQL - XQL
- Tcl Procs
- Tcl pages
- Vi as an OpenACS IDE
- WCAG 1.0 Checkpoints
- Web Forms
- Web Lists / Tables
- template::head::*
- External Resources
- Cookbook
- Cookbook
- Add extra headers
- Creating adp box tags for consistent html/css
- E-Mail: Event Handling
- E-Mail: Incoming E-Mail
- E-Mail: Outgoing E-Mail
- F. A. Q.
- Handling out of memory on "exec" calls
- Host Node Map
- How to configure a Network Place under Windows XP to access file-storage via WebDAV
- How to handle "connection already closed" errors
- How to manage/upgrade CKEditor versions
- Modifying the look of an installation
- OpenACS Performance Tuning
- Passing values up from an include
- Permissions explored, a practical way exists
- Refactoring Recipes
- Running OpenACS behind a proxy
- SQL: How to log (slow) queries in the system log
- Security: Content Security Policy (CSP)
- Security: Cross Site Request Forgery (CSRF)
- Using Pound as a reverse Proxy
- XoWiki: How to save files directly in the wiki
- XoWiki: List of the available includelets
- Resources
- Accessibility
- Testing Pages
- Commit graph
- Commits
- Comparison of the CTRL Surveys Package vs. the OACS Assessment Package
- OpenACS Object Types
- Pastebin for irc
- QUOTA
- Recently Changed Pages
- Wikipedia
- XoWiki Slides from the Vienna OpenACS conference
- category test
- fullpage
- just playing around
- name with space
- preview.png
- toc-test-page