~vil/pydev/upstream

« back to all changes in this revision

Viewing changes to org.python.pydev.jython/Lib/xml/dom/html/HTMLFormElement.py

  • Committer: Vladimír Lapáček
  • Date: 2006-08-30 18:38:44 UTC
  • Revision ID: vladimir.lapacek@gmail.com-20060830183844-f4d82c1239a7770a
Initial import of upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# File Name:            HTMLFormElement.py
 
3
#
 
4
# Documentation:        http://docs.4suite.com/4DOM/HTMLFormElement.py.html
 
5
#
 
6
"""
 
7
WWW: http://4suite.com/4DOM         e-mail: support@4suite.com
 
8
 
 
9
Copyright (c) 2000 Fourthought Inc, USA.   All Rights Reserved.
 
10
See  http://4suite.com/COPYRIGHT  for license and copyright information
 
11
"""
 
12
 
 
13
import string
 
14
from xml.dom import ext
 
15
from xml.dom import implementation
 
16
from xml.dom.html.HTMLElement import HTMLElement
 
17
from xml.dom.html.HTMLCollection import HTMLCollection
 
18
 
 
19
FORM_CHILDREN = ['INPUT',
 
20
                 'SELECT',
 
21
                 'OPTGROUP',
 
22
                 'OPTION',
 
23
                 'TEXTAREA',
 
24
                 'LABEL',
 
25
                 'BUTTON',
 
26
                 'FIELDSET',
 
27
                 'LEGEND',
 
28
                 'OBJECT',
 
29
                 'ISINDEX'
 
30
                 ]
 
31
 
 
32
class HTMLFormElement(HTMLElement):
 
33
 
 
34
    def __init__(self, ownerDocument, nodeName='FORM'):
 
35
        HTMLElement.__init__(self, ownerDocument, nodeName)
 
36
 
 
37
    ### Attribute Methods ###
 
38
 
 
39
    def _get_acceptCharset(self):
 
40
        return self.getAttribute('ACCEPT-CHARSET')
 
41
 
 
42
    def _set_acceptCharset(self,acceptcharset):
 
43
        self.setAttribute('ACCEPT-CHARSET',acceptcharset)
 
44
 
 
45
    def _get_action(self):
 
46
        return self.getAttribute('ACTION')
 
47
 
 
48
    def _set_action(self,action):
 
49
        self.setAttribute('ACTION',action)
 
50
 
 
51
    def _get_elements(self):
 
52
        #Make a collection of control elements
 
53
        nl = self.getElementsByTagName('*')
 
54
        l = []
 
55
        for child in nl:
 
56
            if child.tagName in FORM_CHILDREN:
 
57
                l.append(child)
 
58
        return implementation._4dom_createHTMLCollection(l)
 
59
 
 
60
    def _get_encType(self):
 
61
        return self.getAttribute('ENCTYPE')
 
62
 
 
63
    def _set_encType(self,enctype):
 
64
        self.setAttribute('ENCTYPE',enctype)
 
65
 
 
66
    def _get_length(self):
 
67
        return self._get_elements().length
 
68
 
 
69
    def _get_method(self):
 
70
        return string.capitalize(self.getAttribute('METHOD'))
 
71
 
 
72
    def _set_method(self,method):
 
73
        self.setAttribute('METHOD',method)
 
74
 
 
75
    def _get_name(self):
 
76
        return self.getAttribute('NAME')
 
77
 
 
78
    def _set_name(self,name):
 
79
        self.setAttribute('NAME',name)
 
80
 
 
81
    def _get_target(self):
 
82
        return self.getAttribute('TARGET')
 
83
 
 
84
    def _set_target(self,target):
 
85
        self.setAttribute('TARGET',target)
 
86
 
 
87
    ### Methods ###
 
88
 
 
89
    def reset(self):
 
90
        pass
 
91
 
 
92
    def submit(self):
 
93
        pass
 
94
 
 
95
    ### Attribute Access Mappings ###
 
96
 
 
97
    _readComputedAttrs = HTMLElement._readComputedAttrs.copy()
 
98
    _readComputedAttrs.update ({
 
99
        'acceptCharset' : _get_acceptCharset,
 
100
        'action'        : _get_action,
 
101
        'elements'      : _get_elements,
 
102
        'encType'       : _get_encType,
 
103
        'length'        : _get_length,
 
104
        'method'        : _get_method,
 
105
        'name'          : _get_name,
 
106
        'target'        : _get_target
 
107
        })
 
108
 
 
109
    _writeComputedAttrs = HTMLElement._writeComputedAttrs.copy()
 
110
    _writeComputedAttrs.update ({
 
111
        'acceptCharset' : _set_acceptCharset,
 
112
        'action'        : _set_action,
 
113
        'encType'       : _set_encType,
 
114
        'method'        : _set_method,
 
115
        'name'          : _set_name,
 
116
        'target'        : _set_target
 
117
        })
 
118
 
 
119
    _readOnlyAttrs = filter(lambda k,m=_writeComputedAttrs: not m.has_key(k),
 
120
                     HTMLElement._readOnlyAttrs + _readComputedAttrs.keys())