Package lemon :: Package html :: Package template :: Module dreamweaverMX
[show private | hide private]
[frames | no frames]

Module lemon.html.template.dreamweaverMX

Module desinged to provide an easy interface to allow python programs to output HTML pages based on
Dreamweaver MX Templates *.dwt files.

The module allows you to treat editable regions as member variables of the page.

Basic Use:

    
    from xecos import template
    page = template.Page("C:\xecos\Templates\main.dwt")

    # Preferred method using member variable notation
    page.Content = 'This is the content'        # Assignment overwrites the current text.
    page.Content += '...more content'           # String concatonation appends text to the end of the.
    print page.Content

    # Using mapping notation:
    page['Content'] = 'This is the content'     # Assignment overwrites the current text.
    page['Content'] += '...more content'        # String concatonation appends text to the end of the.
    print page['Content']

    # If 'Content' is the fourth editable region in the template, can access the valus using list notation:
    page[3] = 'This is the content'             # Assignment overwrites the current text.
    page[3] += '...more content'                # String concatonation appends text to the end of the.
    print page[3]

    # If there is more than one editable region we can use slice notation to get an array of values:
    print page[1:2]

    # Demonstrate some features

    page[0] = '0'
    page[1] = '1'
    page[2] = '2'
    page[3] = '3'

    print page[0:4]

    page[1:3] = ['b','c',]
    print page[0:4]

    print page.keys()
    print page.has_key('Content')
    print page.items()
    print page.count('Content')
    print page.index('3')

    # Finally print the whole document complete with the altered editable regions.    
    print page


Important Public Functions:
          
    set(key, value)             # Set the editable region "key" to "value"
    get(key)                    # Get the contents of the editable region "key" as a string
    append(key, value)          # Append the editable region "key" with the string "value"
    output()                    # Return the new page with all the ediable regions included
    asDictionary()              # Return the contents of the editable regions as a dictionary with the region names as keys.
    asList()                    # Return the contents of thr editable regions as a list

    getTemplateRegion(key)      # Get the contents of the editable region "key" as a string from the template
    getTemplateRegions()        # Return the contents of the editable regions of the tamplate as a dictionary

    swapTemplatePaths(new, old) # Used to change the text in the template (not in the Editable Regions). Used to update the links and paths in the template to point to the correct URL

Classes
Page Class to parse Macromedia Dreamweaver MX Template files...

Exceptions
TemplateError Raised when a general Error in the templates.py module occurs Attributes: message -- explanation of what the specific error is.

Variable Summary
str __author__ = 'James Gardner <james@xecos.com>'
str __credits__ = 'Guido van Rossum, for an excellent progra...
str __date__ = '02 February 2003'
str __version__ = '0.2'

Variable Details

__author__

Type:
str
Value:
'James Gardner <james@xecos.com>'                                      

__credits__

Type:
str
Value:
'Guido van Rossum, for an excellent programming language.'             

__date__

Type:
str
Value:
'02 February 2003'                                                     

__version__

Type:
str
Value:
'0.2'                                                                  

Generated by Epydoc 2.0 on Mon Nov 10 15:07:55 2003 http://epydoc.sf.net