Silva has an External Sources extension which gives the ability to add data from non-Silva sources in Silva Documents. These non-Silva, or "external" sources, can for example be a relational database (e.g. addresses, price-listings, course info, etc.) or the outcome of executing a Python script (which could e.g. make an RSS feed available for Silva Documents).
Since an external source can potentially be resource intensive or expose a vulnerability, only users with ZMI access (Zope Management Interface, usually the site managers) can create external sources. The exception to this rule is the CSV Source object because its possibilities are limited. A CSV source can be created from the Silva Management Area by an Author. It is the site administrator's responsibility to make sure no vulnerabilities are exposed to the Authors or the public website. This does imply the site administrator needs to be knowledgeable of both Silva and the external source being accessed.
An external source added to a Silva site also offers the author a set of parameters (via a Formulator form) to aid layout of the external source within the Silva Document.
5. Scroll down and click onto “service_extensions (Silva Product and Extensions Configuration)”.
6. To make the Silva External Sources work in a particular Silva root, the install button needs to be clicked for this extension. This install button is to be found in the service_extensions, available in the Services-tab in the Zope Management Interface of this Silva root. Click install in the SilvaExternalSources box.
The SQL Source allows an SQL query in a table. Because of the security issues mentioned above, only Zope managers are allowed to create them. Authors can place references to an SQL Source into their documents.
1. Go to the ZMI (Zope Management Interface) and navigate to the Silva root.
2. Select Silva SQL Source from the drop-down menu.
3. Fill in id and title and press Add and Edit.
4. If the displayed SQL connection isn't the one you want, choose a different one; check if the data encoding is the same as your database delivers; enter the sql statement you want to be executed.
5. Save the changes
6. Test the query via the Test tab.
If everything went well, the SQL Source can now be used in documents.
In a document, select External Source as the element to insert and choose the newly created SQL Source. Then press the update button next to the drop down list.
In the form that appears the author can adjust the appearance of the table to be displayed and can add a caption if needed.
The Edit tab of the SQL Source in the ZMI contains a link called edit parameters. With this link a Formulator form can be changed, which displays when the SQL source is referenced from a document. Of course, one needs to know how to manage forms with Formulator – this is out of scope for this guide.
CSV Source displays data that is uploaded in a format called ‘comma separated values’. CSV is a plain text format where each line contains a row of a table; the columns within a row are delimited by commas. We then have a tabular structure to present to the viewer.
Something important to note with the CSV Sources is the encoding of the data that will be uploaded. For this guide it is enough to say that the encoding of the data describes the way the characters are represented.
Another difference is that the parameter form shown when the CSV Source is referenced from a document is not changeable.
Example:
When you save your Excel-Sheet as .csv, Excel uses one of the windows encodings. For most western European countries
(EURO land:) this will be ‘cp1252’. Of course you have to know the name of the encoding before you upload the data.
In the edit view of the CSV Source you can change the encoding after the data was uploaded. If you experience strange visual effects, try another encoding.
In the edit view you also can upload another file, which replaces the actual data, or apply manual changes to the data.
The most important aspect of CSV Sources is you can insert references to them into documents.
CSV Sources behave like normal assets, so you can specify some parameters which are attached to the document. For CSV Sources these parameters consist of the table style to use and the number of rows to show if the table is long and needs batching.
2. Add a CSV Source via the drop down select list.
3. Fill in the form, browse to select 'filename.csv' on your drive, and click the Add button.
4. In the Silva Management Area an Author can now access this asset and place it inside a document in the forms editor, by adding an “external source” from the drop down add element list.
5. In the edit form, select the asset (in this case “Income Source”) from the drop down list and click update.
6. To view the data click on public preview.
7. Publish the document.
Changes to the data of the CSVSource are done by uploading a new set of data or editing the raw data via the edit screen. A re-publication of the document is not necessary.
The table layout is the standard table layout Silva uses for its tables. But there is, as always, the possibility to modify the page template which creates the html table.
The Code Source element is a feature for including dynamically generated html into a document. It resembles a Python Script but is a bit more complex.
Code Sources can only be created on the Zope level and need Manager rights. Here is a list of the steps to take:
Now the Code Source can be used from within a document.
The procedure is the same as with the other External Sources; the part about the parameter form also applies here.
© Copyright 2002-2004 Infrae.
All rights reserved.