Docs for SQLTABLE

[ Python Tutorial ] [ Python Libraries ] [ web2py epydoc ]

Description


<type 'type'> extends (<class 'gluon.html.TABLE'>,)











































































given a Rows object, as returned by a db().select(), generates
an html table with the rows.

optional arguments:

:
param linkto: URL (or lambda to generate a URL) to edit individual records
:param upload: URL to download uploaded files
:param orderby: Add an orderby link to column headers.
:
param headers: dictionary of headers to headers redefinions
headers can also be a string to gerenare the headers from data
for now only headers="fieldname:capitalize",
headers="labels" and headers=None are supported
:param truncate: length at which to truncate text in table cells.
Defaults to 16 characters.
:
param columns: a list or dict contaning the names of the columns to be shown
Defaults to all

Optional names attributes for passed to the <table> tag

The keys of headers and columns must be of the form "tablename.fieldname"

Simple linkto example::

rows = db.select(db.sometable.ALL)
table = SQLTABLE(rows, linkto='someurl')

This will link rows[id] to .../sometable/value_of_id


More advanced linkto example::

def mylink(field, type, ref):
return URL(args=[field])

rows = db.select(db.sometable.ALL)
table = SQLTABLE(rows, linkto=mylink)

This will link rows[id] to
current_app/current_controlle/current_function/value_of_id

New Implements: 24 June 2011:
-----------------------------

:
param selectid: The id you want to select
:param renderstyle: Boolean render the style with the table

:param extracolums = [{'label':A('Extra',_href='#'),
'class': '', #class name of the header
'width':'', #width in pixels or %
'content':lambda row, rc: A('Edit',_href='edit/%s'%row.id),
'selected': False #agregate class selected to this column
}]


:
param headers = {'table.id':{'label':'Id',
'class':'', #class name of the header
'width':'', #width in pixels or %
'truncate': 16, #truncate the content to...
'selected': False #agregate class selected to this column
},
'table.myfield':{'label':'My field',
'class':'', #class name of the header
'width':'', #width in pixels or %
'truncate': 16, #truncate the content to...
'selected': False #agregate class selected to this column
},
}

table = SQLTABLE(rows, headers=headers, extracolums=extracolums)




Attributes


SQLTABLE.__class__ <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
type(object) -> the object's type type(name, bases, dict) -> a new type

SQLTABLE.__delattr__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__delattr__('name') <==> del x.name

SQLTABLE.__delitem__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
deletes attribute with name 'i' or component #i. :param i: index if i is a string: the name of the attribute otherwise references to number of the component

SQLTABLE.__dict__ <type 'dictproxy'> belongs to class <type 'dictproxy'>

SQLTABLE.__doc__ <type 'str'> belongs to class <type 'str'>
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SQLTABLE.__getattribute__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__getattribute__('name') <==> x.name

SQLTABLE.__getitem__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
gets attribute with name 'i' or component #i. If attribute 'i' is not found returns None :param i: index if i is a string: the name of the attribute otherwise references to number of the component

SQLTABLE.__hash__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__hash__() <==> hash(x)

SQLTABLE.__init__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

SQLTABLE.__len__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
returns the number of included components

SQLTABLE.__module__ <type 'str'> belongs to class <type 'str'>
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SQLTABLE.__new__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
T.__new__(S, ...) -> a new object with type S, a subtype of T

SQLTABLE.__nonzero__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
always return True

SQLTABLE.__reduce__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
helper for pickle

SQLTABLE.__reduce_ex__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
helper for pickle

SQLTABLE.__repr__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__repr__() <==> repr(x)

SQLTABLE.__setattr__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__setattr__('name', value) <==> x.name = value

SQLTABLE.__setitem__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
sets attribute with name 'i' or component #i. :param i: index if i is a string: the name of the attribute otherwise references to number of the component :param value: the new value

SQLTABLE.__str__ <type 'instancemethod'> belongs to class <type 'instancemethod'>
str(COMPONENT) returns equals COMPONENT.xml()

SQLTABLE.__weakref__ <type 'getset_descriptor'> belongs to class <type 'getset_descriptor'>
list of weak references to the object (if defined)

SQLTABLE._fixup <type 'instancemethod'> belongs to class <type 'instancemethod'>

SQLTABLE._postprocessing <type 'instancemethod'> belongs to class <type 'instancemethod'>
Handling of attributes (normally the ones not prefixed with '_'). Nothing to postprocess yet. May be overridden by subclasses

SQLTABLE._setnode <type 'instancemethod'> belongs to class <type 'instancemethod'>

SQLTABLE._traverse <type 'instancemethod'> belongs to class <type 'instancemethod'>

SQLTABLE._validate <type 'instancemethod'> belongs to class <type 'instancemethod'>
nothing to validate yet. May be overridden by subclasses

SQLTABLE._wrap_components <type 'instancemethod'> belongs to class <type 'instancemethod'>
helper for _fixup. Checks if a component is in allowed_parents, otherwise wraps it in wrap_parent :param allowed_parents: (tuple) classes that the component should be an instance of :param wrap_parent: the class to wrap the component in, if needed :param wrap_lambda: lambda to use for wrapping, if needed

SQLTABLE._xml <type 'instancemethod'> belongs to class <type 'instancemethod'>
helper for xml generation. Returns separately: - the component attributes - the generated xml of the inner components Component attributes start with an underscore ('_') and do not have a False or None value. The underscore is removed. A value of True is replaced with the attribute name. :returns: tuple: (attributes, components)

SQLTABLE.append <type 'instancemethod'> belongs to class <type 'instancemethod'>
list style appending of components >>> a=DIV() >>> a.append(SPAN('x')) >>> print a <div><span>x</span></div>

SQLTABLE.element <type 'instancemethod'> belongs to class <type 'instancemethod'>
find the first component that matches the supplied attribute dictionary, or None if nothing could be found Also the components of the components are searched.

SQLTABLE.elements <type 'instancemethod'> belongs to class <type 'instancemethod'>
find all component that match the supplied attribute dictionary, or None if nothing could be found All components of the components are searched. >>> a = DIV(DIV(SPAN('x'),3,DIV(SPAN('y')))) >>> for c in a.elements('span',first_only=True): c[0]='z' >>> print a <div><div><span>z</span>3<div><span>y</span></div></div></div> >>> for c in a.elements('span'): c[0]='z' >>> print a <div><div><span>z</span>3<div><span>z</span></div></div></div> It also supports a syntax compatible with jQuery >>> a=TAG('<div><span><a id="1-1" u:v=$>hello</a></span><p class="this is a test">world</p></div>') >>> for e in a.elements('div a#1-1, p.is'): print e.flatten() hello world >>> for e in a.elements('#1-1'): print e.flatten() hello >>> a.elements('a[u:v=$]')[0].xml() '<a id="1-1" u:v="$">hello</a>' >>> a=FORM( INPUT(_type='text'), SELECT(range(1)), TEXTAREA() ) >>> for c in a.elements('input, select, textarea'): c['_disabled'] = 'disabled' >>> a.xml() '<form action="" enctype="multipart/form-data" method="post"><input disabled="disabled" type="text" /><select disabled="disabled"><option value="0">0</option></select><textarea cols="40" disabled="disabled" rows="10"></textarea></form>'

SQLTABLE.flatten <type 'instancemethod'> belongs to class <type 'instancemethod'>
return the text stored by the DIV object rendered by the render function the render function must take text, tagname, and attributes render=None is equivalent to render=lambda text, tag, attr: text >>> markdown = lambda text,tag=None,attributes={}: {None: re.sub('\s+',' ',text), 'h1':'#'+text+'\n\n', 'p':text+'\n'}.get(tag,text) >>> a=TAG('<h1>Header</h1><p>this is a test</p>') >>> a.flatten(markdown) '#Header\n\nthis is a test\n'

SQLTABLE.insert <type 'instancemethod'> belongs to class <type 'instancemethod'>
list style inserting of components >>> a=DIV() >>> a.insert(0,SPAN('x')) >>> print a <div><span>x</span></div>

SQLTABLE.regex_attr <type '_sre.SRE_Pattern'>
Compiled regular expression objects

SQLTABLE.regex_class <type '_sre.SRE_Pattern'>
Compiled regular expression objects

SQLTABLE.regex_id <type '_sre.SRE_Pattern'>
Compiled regular expression objects

SQLTABLE.regex_tag <type '_sre.SRE_Pattern'>
Compiled regular expression objects

SQLTABLE.sibling <type 'instancemethod'> belongs to class <type 'instancemethod'>
find the first sibling component that match the supplied argument list and attribute dictionary, or None if nothing could be found

SQLTABLE.siblings <type 'instancemethod'> belongs to class <type 'instancemethod'>
find all sibling components that match the supplied argument list and attribute dictionary, or None if nothing could be found

SQLTABLE.style <type 'instancemethod'> belongs to class <type 'instancemethod'>

SQLTABLE.tag <type 'str'> belongs to class <type 'str'>
str(object) -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SQLTABLE.update <type 'instancemethod'> belongs to class <type 'instancemethod'>
dictionary like updating of the tag attributes

SQLTABLE.xml <type 'instancemethod'> belongs to class <type 'instancemethod'>
generates the xml for this component.