View · Index

Code Formatting

  • Use 4 space indentation 
  • Code lines must not exceed 80 characters in length. Never use a single line that has more than 80 chars.
  • Source files should be coded in UTF-8 using Unix-style newlines

These general rules are applicable to Tcl & SQL.

Also, the 80 character limit is important because the OpenACS API browser (at /api-doc/) presents documentation defined in ad_proc's doc_string declaration in html format; whereas ad_proc's body of code is presented wrapped in PRE tags. Longer code lines result in API documentation pages (and their paragraphs) stretching outside of typical browser window width.

If you are using Emacs editor, you usually are on the safe side with regards to Tcl, as the tcl-mode indents just as we want it. ADP pages are formatted correctly when editor is in html-mode.

Formatting SQL Statements

  • A proper format for select statements is
    select ....
    from ....
    where clause
        and clause
        and clause
  • A proper format for insert statements (and note the indentation and overflow of attributes)
    insert into table_name
      (c1, c2, c3 ...
       cx, cy, cz)
    values
      (v1, v2, v3 ...
       vx, vy, vz)
  • A proper format for update statements:
    update table
    set c1=v1,
         c2=v2,
         ...
    where ...

Editor modes

There is an OpenACS mode for emacs OpenACS mode for Emacs which has features to help meet formatting standards.

One can add the following stanza to the end of a .tcl file, when using Emacs, to avoid, that spaces are changed again into tabs.

#
# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End:

 

Security Considerations

Allowing user input to include images, see patch in this discussion thread: https://openacs.org/forums/message-view?message_id=182057

previous October 2024
Sun Mon Tue Wed Thu Fri Sat
29 30 1 (1) 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2

Popular tags

17 , 5.10 , 5.10.0 , 5.10.1 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bootstrap , bugtracker , CentOS , COMET , compatibility , CSP , CSRF , cvs , debian , docker , docker-compose , emacs , engineering-standards , exec , fedora , FreeBSD , guidelines , host-node-map
1 registered user in community xowiki
in last 30 minutes
Contributors

OpenACS.org