class EditForm(base.EditForm): """ """ label = _(u"Edit the Plomino Design Portlet") description = _( u"This portlet provides access to Plomino design features.") form_fields = form.Fields(IPortlet)
class IPortlet(Interface): display_tree = schema.Choice( title=_("Display design tree"), description=_(u"Embed the full design tree in the portlet."), vocabulary=schema.vocabulary.SimpleVocabulary.fromItems( [('Yes', True), ('No', False)]), required=True)
def validate(self, submittedValue): """ """ errors = [] fieldname = self.context.id if self.type == "INTEGER": try: v = long(submittedValue) except: errors.append(fieldname + PlominoTranslate( _(" must be an integer (submitted value was: "), self.context) + submittedValue + ")") elif self.type == "FLOAT": try: v = float(submittedValue) except: errors.append(fieldname + PlominoTranslate( _(" must be a float (submitted value was: "), self.context) + submittedValue + ")") elif self.type == "DECIMAL": try: v = Decimal(str(submittedValue)) except: errors.append(fieldname + PlominoTranslate( _(" must be a decimal (submitted value was: "), self.context) + submittedValue + ")") return errors
class AddForm(base.AddForm): label = _(u"Add a Plomino Element Portlet") description = _(u"This portlet provides access to Plomino design features.") form_fields = form.Fields(IPortlet) def create(self, data): return Assignment(**data)
class ElementPortletAddForm(base.AddForm): """Creates a portlet used to display a Plomino element everywhere in a Plone site """ label = _(u"Add a Plomino Element Portlet") description = _(u"This portlet displays an element of a Plomino database.") form_fields = form.Fields(IElementPortlet) def create(self, data): return ElementPortletAssignment(**data)
def deleteAttachment(self, REQUEST=None, fieldname=None, filename=None): """ Remove file object and update corresponding item value. """ if REQUEST: fieldname = REQUEST.get('field') filename = REQUEST.get('filename') if fieldname and filename: current_files = self.getItem(fieldname) if current_files.has_key(filename): if len(current_files.keys()) == 1: # if it is the only file attached, we need to make sure # the field is not mandatory, to allow deletion form = self.getForm() if form: field = form.getFormField(fieldname) if field and field.getMandatory(): error = "%s %s" % (fieldname, PlominoTranslate( _("is mandatory"), self)) return form.notifyErrors([error]) del current_files[filename] self.setItem(fieldname, current_files) self.deletefile(filename) if REQUEST: REQUEST.RESPONSE.redirect(self.absolute_url() + "/EditDocument")
def getActionLabel(self, action_id): """ """ db = self.context.getParentDatabase() if action_id == "add": label = PlominoTranslate(_("datagrid_add_button_label", default="Add"), db) child_form_id = self.associated_form if child_form_id: child_form = db.getForm(child_form_id) if child_form: label += " "+child_form.Title() return label elif action_id == "delete": return PlominoTranslate(_("datagrid_delete_button_label", default="Delete"), db) elif action_id == "edit": return PlominoTranslate(_("datagrid_edit_button_label", default="Edit"), db) return ""
class Assignment(base.Assignment): implements(IPortlet) title = _('Plomino design portlet') display_tree = True def __init__(self, display_tree=True): self.display_tree = display_tree
class ElementPortletAssignment(base.Assignment): """ Initialises a Plomino Element portlet """ implements(IElementPortlet) title = _(u'Plomino Element Display') header = u"" db_path = "" element_id = "" def __init__(self, header=u"", db_path="", element_id=""): self.header = header self.db_path = db_path self.element_id = element_id
def validate(self, submittedValue): """ """ errors = [] fieldname = self.context.id if self.type == "INTEGER": try: v = long(submittedValue) except: errors.append( fieldname + PlominoTranslate( _(" must be an integer (submitted value was: "), self.context) + submittedValue + ")") elif self.type == "FLOAT": try: v = float(submittedValue) except: errors.append( fieldname + PlominoTranslate( _(" must be a float (submitted value was: "), self.context) + submittedValue + ")") elif self.type == "DECIMAL": try: v = Decimal(str(submittedValue)) except: errors.append( fieldname + PlominoTranslate( _(" must be a decimal (submitted value was: "), self.context) + submittedValue + ")") return errors
class IElementPortlet(Interface): """Contains the template used to fill a template form """ header = schema.TextLine(title=_(u"Portlet header"), description=_(u"Title of the rendered portlet"), required=True) db_path = schema.TextLine(title=_(u"Database path"), description=_(u"Path of the database where the element is stored"), required=True) element_id = schema.TextLine(title=_(u"Element ID"), description=_(u"ID of the form to be displayed"), required=True)
from Products.CMFPlomino.browser import PlominoMessageFactory as _ from validator import isValidPlominoId import interfaces import logging logger = logging.getLogger('Plomino') schema = Schema( ( StringField( name='id', widget=StringField._properties['widget']( label="Id", description= "If changed after creation, database refresh is needed", label_msgid=_('CMFPlomino_label_view_id', default="Id"), description_msgid=_( 'CMFPlomino_help_view_id', default= "If changed after creation, database refresh is needed"), i18n_domain='CMFPlomino', ), validators=("isValidId", isValidPlominoId), ), TextField( name='SelectionFormula', widget=TextAreaWidget( label="Selection formula", description="""The view selection formula is a line of Python code which should return True or False. The formula will be evaluated for each document in the database to decide if the document must be displayed in
] ACTION_DISPLAY = [ ["LINK", "Link"], ["SUBMIT", "Submit button"], ["BUTTON", "Button"] ] ##/code-section module-header schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The action id", label_msgid=_('CMFPlomino_label_action_id', default="Id"), description_msgid=_('CMFPlomino_help_action_id', default="The action id"), i18n_domain='CMFPlomino', ), ), StringField( name='ActionType', widget=SelectionWidget( label="Action type", description="Select the type for this action", label_msgid=_('CMFPlomino_label_ActionType', default="Select the type for this action"), description_msgid=_('CMFPlomino_help_ActionType', default='Select the type for this action'), i18n_domain='CMFPlomino', ), vocabulary=ACTION_TYPES, ),
class ElementPortletEditForm(base.EditForm): """Edit a portlet used to display a Plomino element everywhere in a Plone site """ label = _(u"Edit a Plomino Element Portlet") description = _(u"This portlet displays an element of a Plomino database.") form_fields = form.Fields(IElementPortlet)
ASYNC = True except: ASYNC = False PLOMINO_REQUEST_CACHE_KEY = "plomino.cache" ##/code-section module-header schema = Schema(( TextField( name='AboutDescription', allowable_content_types=('text/html',), widget=RichWidget( label="About this database", description="Describe the database, its objectives, " "its targeted audience, etc...", label_msgid=_('CMFPlomino_label_AboutDescription'), description_msgid=_('CMFPlomino_help_AboutDescription', default='Describe the database, its objectives, its targeted audience, etc...'), i18n_domain='CMFPlomino', ), default_output_type="text/html", ), TextField( name='UsingDescription', allowable_content_types=('text/html',), widget=RichWidget( label="Using this database", description="Describe how to use the database", label_msgid=_('CMFPlomino_label_UsingDescription', default="Using this database"), description_msgid=_('CMFPlomino_help_UsingDescription', default="Describe how to use the database"), i18n_domain='CMFPlomino',
from Products.Archetypes.atapi import * from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin # Plomino from exceptions import PlominoScriptException from Products.CMFPlomino.config import * from Products.CMFPlomino.browser import PlominoMessageFactory as _ import interfaces schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The agent id", label_msgid=_('CMFPlomino_label_agent_id', default="Id"), description_msgid=_('CMFPlomino_help_agent_id', default="The agent id"), i18n_domain='CMFPlomino', ), ), TextField( name='Content', widget=TextAreaWidget( label="Code", description="Code to execute", label_msgid=_("CMFPlomino_label_AgentContent", default="Code to execute"), description_msgid=_("CMFPlomino_help_AgentContent", default='Code to execute'), i18n_domain='CMFPlomino', rows=25, ), ),
from fields.doclink import IDoclinkField from ZPublisher.HTTPRequest import FileUpload from zope import component from zope.annotation.interfaces import IAnnotations from persistent.dict import PersistentDict import logging logger = logging.getLogger('Plomino') schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The field id", label_msgid=_('CMFPlomino_label_field_id', default="Id"), description_msgid=_('CMFPlomino_help_field_id', default="The field id"), i18n_domain='CMFPlomino', ), ), StringField( name='FieldType', default="TEXT", widget=SelectionWidget( label="Field type", description="The kind of this field", label_msgid=_('CMFPlomino_label_FieldType', default="Field type"), description_msgid=_('CMFPlomino_help_FieldType', default='The kind of this field'), i18n_domain='CMFPlomino',
from Products.Archetypes.atapi import * from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin # Plomino from exceptions import PlominoScriptException from Products.CMFPlomino.config import * from Products.CMFPlomino.browser import PlominoMessageFactory as _ import interfaces schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The agent id", label_msgid=_('CMFPlomino_label_agent_id', default="Id"), description_msgid=_('CMFPlomino_help_agent_id', default="The agent id"), i18n_domain='CMFPlomino', ), ), TextField( name='Content', widget=TextAreaWidget( label="Code", description="Code to execute", label_msgid=_("CMFPlomino_label_AgentContent", default="Code to execute"), description_msgid=_("CMFPlomino_help_AgentContent", default='Code to execute'), i18n_domain='CMFPlomino',
from PlominoUtils import asUnicode, asList from Products.CMFPlomino.config import * from Products.CMFPlomino.browser import PlominoMessageFactory as _ from validator import isValidPlominoId import interfaces import logging logger = logging.getLogger('Plomino') schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="If changed after creation, database refresh is needed", label_msgid=_('CMFPlomino_label_view_id', default="Id"), description_msgid=_('CMFPlomino_help_view_id', default="If changed after creation, database refresh is needed"), i18n_domain='CMFPlomino', ), validators = ("isValidId", isValidPlominoId), ), TextField( name='SelectionFormula', widget=TextAreaWidget( label="Selection formula", description="""The view selection formula is a line of Python code which should return True or False. The formula will be evaluated for each document in the database to decide if the document must be displayed in the view or not. 'plominoDocument' is a reserved name in formulae: it returns the current Plomino document.""", label_msgid=_('CMFPlomino_label_SelectionFormula', default="Selection formula"),
from ZPublisher.HTTPRequest import FileUpload from zope import component from zope.annotation.interfaces import IAnnotations from persistent.dict import PersistentDict import logging logger = logging.getLogger('Plomino') schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The field id", label_msgid=_('CMFPlomino_label_field_id', default="Id"), description_msgid=_('CMFPlomino_help_field_id', default="The field id"), i18n_domain='CMFPlomino', ), ), StringField( name='FieldType', default="TEXT", widget=SelectionWidget( label="Field type", description="The kind of this field", label_msgid=_('CMFPlomino_label_FieldType', default="Field type"), description_msgid=_('CMFPlomino_help_FieldType', default='The kind of this field'), i18n_domain='CMFPlomino', ), vocabulary='type_vocabulary',
from Products.CMFPlomino.config import PROJECTNAME from Products.CMFPlomino.browser import PlominoMessageFactory as _ from validator import isValidPlominoId from Products.CMFPlomino.PlominoUtils import translate import logging logger = logging.getLogger('Plomino') schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="Column id", label_msgid=_('CMFPlomino_label_column_id', default="Id"), description_msgid=_('CMFPlomino_help_column_id', default="Column id"), i18n_domain='CMFPlomino', ), validators=("isValidId", isValidPlominoId), ), StringField( name='SelectedField', widget=SelectionWidget( label="Fields list", description=("Field value to display in the column. " "(It does not apply if Formula is provided)."), # label_msgid=_('CMFPlomino_label_FieldType'), # description_msgid=_('CMFPlomino_help_FieldType'), # i18n_domain='CMFPlomino', ),
import interfaces from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin from Products.CMFPlomino.config import PROJECTNAME from Products.CMFPlomino.browser import PlominoMessageFactory as _ from validator import isValidPlominoId schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="Column id", label_msgid=_('CMFPlomino_label_column_id', default="Id"), description_msgid=_('CMFPlomino_help_column_id', default="Column id"), i18n_domain='CMFPlomino', ), validators=("isValidId", isValidPlominoId), ), StringField( name='SelectedField', widget=SelectionWidget( label="Fields list", description=("Field value to display in the column. " "(It does not apply if Formula is provided)."), # label_msgid=_('CMFPlomino_label_FieldType'), # description_msgid=_('CMFPlomino_help_FieldType'), # i18n_domain='CMFPlomino', ),
# Plone from Products.CMFPlomino.config import * from Products.CMFPlomino.browser import PlominoMessageFactory as _ import interfaces ##code-section module-header #fill in your manual code here ##/code-section module-header schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The hide-when id", label_msgid=_('CMFPlomino_label_hidewhen_id', default="Id"), description_msgid=_('CMFPlomino_help_hidewhen_id', default="The hide-when id"), i18n_domain='CMFPlomino', ), ), TextField( name='Formula', widget=TextAreaWidget( label="Formula", description="If returning True, the block will be hidden.", label_msgid=_('CMFPlomino_label_HidewhenFormula', default="Formula"), description_msgid=_('CMFPlomino_help_HidewhenFormula', default='If returning True, the block will be hidden.'), i18n_domain='CMFPlomino', ), ), BooleanField(
ASYNC = True except: ASYNC = False PLOMINO_REQUEST_CACHE_KEY = "plomino.cache" ##/code-section module-header schema = Schema(( TextField( name='AboutDescription', allowable_content_types=('text/html', ), widget=RichWidget( label="About this database", description="Describe the database, its objectives, " "its targeted audience, etc...", label_msgid=_('CMFPlomino_label_AboutDescription'), description_msgid=_( 'CMFPlomino_help_AboutDescription', default= 'Describe the database, its objectives, its targeted audience, etc...' ), i18n_domain='CMFPlomino', ), default_output_type="text/html", ), TextField( name='UsingDescription', allowable_content_types=('text/html', ), widget=RichWidget( label="Using this database", description="Describe how to use the database",
# Plone from Products.CMFPlomino.config import * from Products.CMFPlomino.browser import PlominoMessageFactory as _ import interfaces ##code-section module-header #fill in your manual code here ##/code-section module-header schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The hide-when id", label_msgid=_('CMFPlomino_label_hidewhen_id', default="Id"), description_msgid=_('CMFPlomino_help_hidewhen_id', default="The hide-when id"), i18n_domain='CMFPlomino', ), ), TextField( name='Formula', widget=TextAreaWidget( label="Formula", description="If returning True, the block will be hidden.", label_msgid=_('CMFPlomino_label_HidewhenFormula', default="Formula"), description_msgid=_( 'CMFPlomino_help_HidewhenFormula', default='If returning True, the block will be hidden.'),
##code-section module-header #fill in your manual code here ACTION_TYPES = [["OPENFORM", "Open form"], ["OPENVIEW", "Open view"], ["CLOSE", "Close"], ["SAVE", "Save"], ["PYTHON", "Python script"], ["REDIRECT", "Redirect formula"]] ACTION_DISPLAY = [["LINK", "Link"], ["SUBMIT", "Submit button"], ["BUTTON", "Button"]] ##/code-section module-header schema = Schema(( StringField( name='id', widget=StringField._properties['widget']( label="Id", description="The action id", label_msgid=_('CMFPlomino_label_action_id', default="Id"), description_msgid=_('CMFPlomino_help_action_id', default="The action id"), i18n_domain='CMFPlomino', ), ), StringField( name='ActionType', widget=SelectionWidget( label="Action type", description="Select the type for this action", label_msgid=_('CMFPlomino_label_ActionType', default="Select the type for this action"), description_msgid=_('CMFPlomino_help_ActionType', default='Select the type for this action'), i18n_domain='CMFPlomino',