def on_error(self):
     '''
     What to do in case of error
     '''
     self.sqlstatus = False
     msg = _("Error executing query")
     logger.exception(msg)
     sm = IStatusMessage(self.request)
     sm.addStatusMessage(msg, 'error')
from Products.Archetypes import atapi
from redturtle.sqlcontents import sqlcontentsMessageFactory as _
from redturtle.sqlcontents.config import PROJECTNAME
from redturtle.sqlcontents.interfaces.sqlfolder import ISQLFolder
from zope.interface import implements

SQLFolderSchema = folder.ATFolderSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
    atapi.StringField(
        'connection_url',
        storage=atapi.AnnotationStorage(),
        required=True,
        mode='w',
        widget=atapi.StringWidget(
            label=_(u"Connection string"),
            description=_("help_connection_url",
                          u"Connection URL compliant with the RFC-1738 "
                          u"standard, for example "
                          u"postgresql://*****:*****@127.0.0.1:5432/testdb"),
            ),
    )
))

# Set storage on fields copied from ATFolderSchema, making sure
# they work well with the python bridge properties.

SQLFolderSchema['title'].storage = atapi.AnnotationStorage()
SQLFolderSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(
from Products.DataGridField import DataGridField, DataGridWidget, Column
from redturtle.sqlcontents import sqlcontentsMessageFactory as _
from redturtle.sqlcontents.config import PROJECTNAME
from redturtle.sqlcontents.interfaces.sqlquery import ISQLQuery
from zope.interface import implements


SQLQuerySchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
    atapi.TextField(
        'query',
         storage=atapi.AnnotationStorage(),
         required=True,
         widget=atapi.TextAreaWidget(
         label=_(u"The query that should be executed"),
         description=_("help_query",
                       (u"For example "
                        u"SELECT * FROM TABLE LIMIT 10")),
            ),
    ),
    DataGridField(
        'column_names',
        storage=atapi.AnnotationStorage(),
        required=False,
        searchable=False,
        allow_delete=True,
        allow_insert=True,
        allow_reorder=True,
        columns=("key", "value"),
        widget=DataGridWidget(