I do not understand the question. What are lasses?
> 2. The attributes that the tags take
The tag objects are transparent to attributes that start by _, for
example:
>>> DIV('hello',H1('world'),_bla=5).xml()
<div bla="5">hello<h1>world</h1></div>
The only two non _ attributes are "requires" for input fields and
textares and "value". Value works like "_value" for input but plays
the role of selected for SELECT/OPTION and act as content for a
TEXTAREA. Examples
>>> SELECT('a','b','c',_name='test',value='b').xml()
<select name="test">
<option value='a'>a</option>
<option value='b' selected>b</option>
<option value='c'>c</option>
</select>
>>> TEXTAREA(_name='x',value="Hello World").ml()
<textarea name="x">HelloWorld</textarea>
> 3. Can the tags take default values?
You can create your own tag with
class myDIV(DIV):
default_attributes={'_style':'color: red;'}
def __init__(self,*components,**attributes):
DIV.__init__(self,*components,**attributes)
import copy
self.attributes=copy.copy(self.default_attributes)
for k,v in attributes.items(): self.attributes[k]=v
>> myDIV('hello',H1('world'),_id='test').xml()
<div id="test" style="color: red;">hello<h1>world</h1></div>
> 4. I18n for the tags, how could this be realized
Gluon doed not use the i18n module, has its own internationalization.
You can do this :
>>> H1(T("welcome")).xml()
<h1>ciao</h1>
(assuming Accept-Language is 'it' and 'it.py' says that "welcome" is
"ciao" in Italian).
>>> DIV('test',_class='myclass').xml()
<div class="myclass">test</div>
(this is why you have to use _ )
you can also do _onload, _onclick, etc. for ajax effects but you have
to use some ajax library.
In [81]: item=range(10)
In [82]: print str(TAG.items(*[TAG.item(i,_id=str(i)) for i in item]))