formalchemy.ext.rdf – rdfalchemy support

This module provides an experimental subclass of FieldSet to support RDFAlchemy.

Usage

>>> from rdfalchemy.samples.company import Company
>>> c = Company(stockDescription='description', symbol='FA',
...             cik='cik', companyName='fa corp',
...             stock=['value1'])
>>> fs = FieldSet(Company)
>>> fs.configure(options=[fs.stock.set(options=['value1', 'value2'])])
>>> fs = fs.bind(c)
>>> fs.stock.value
['value1']
>>> print fs.render().strip() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
<div>
  <label class="field_opt" for="Company--stockDescription">Stockdescription</label>
  <input id="Company--stockDescription" name="Company--stockDescription" type="text" value="description" />
</div>
...
<div>
  <label class="field_opt" for="Company--stock">Stock</label>
  <select id="Company--stock" name="Company--stock">
<option selected="selected" value="value1">value1</option>
<option value="value2">value2</option>
</select>
</div>
>>> fs = Grid(Company, [c])
>>> fs.configure(options=[fs.stock.set(options=['value1', 'value2'])], readonly=True)
>>> print fs.render().strip() #doctest: +NORMALIZE_WHITESPACE
<thead>
  <tr>
      <th>Stockdescription</th>
      <th>Companyname</th>
      <th>Cik</th>
      <th>Symbol</th>
      <th>Stock</th>
  </tr>
</thead>
<tbody>
  <tr class="even">
    <td>description</td>
    <td>fa corp</td>
    <td>cik</td>
    <td>FA</td>
    <td>value1</td>
  </tr>
</tbody>

Classes definitions

Field

class formalchemy.ext.rdf.Field(name=None, type=<class 'sqlalchemy.types.String'>, value=None, **kwattrs)

Create a new Field object.

  • name:

    field name

  • type=types.String:

    data type, from formalchemy.types (Integer, Float, String, Binary, Boolean, Date, DateTime, Time) or a custom type

  • value=None:

    default value. If value is a callable, it will be passed the current bound model instance when the value is read. This allows creating a Field whose value depends on the model once, then binding different instances to it later.

    • name: field name
    • type: data type, from formalchemy.types (Boolean, Integer, String, etc.), or a custom type for which you have added a renderer.
    • value: default value. If value is a callable, it will be passed the current bound model instance when the value is read. This allows creating a Field whose value depends on the model once, then binding different instances to it later.

FieldSet

class formalchemy.ext.rdf.FieldSet(model, session=None, data=None, prefix=None)

Grid

class formalchemy.ext.rdf.Grid(cls, instances=[], session=None, data=None, prefix=None)

Table Of Contents

Previous topic

formalchemy.ext.pylons – Pylons extensions

Next topic

formalchemy.ext.zope – zope.schema support

This Page