# -*- coding: utf-8 # Copyright 2006 by Pjotr Savitski from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField, TextField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget from Products.Archetypes.public import OrderedBaseFolder, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema + Schema(( # This text field is not used in Prototype one #(meant to be used for creating dynamical content) TextField('iCharr', required=0, accessor="getiCharr", searchable=0, isMetadata=0, default='', default_output_type='text/plain', widget=TextAreaWidget( cols=40, rows=3, visible={'edit':'invisible','view':'invisible'}, label="List of ontoligical options", label_msgid='label_icharr', description="Every option gets a new line. Each line should consist of title and maximum (e.g. SQI implementation status,10).", description_msgid='description_icharr', i18n_domain="plone"), ), StringField('iListObjectValues', required=0, accessor="getiListObjectValues", searchable=0, isMetadata=0, widget=StringWidget( size=50, visible={'edit':'visible','view':'invisible'}, label="List of values", label_msgid='label_ilistobjectvalues', description="Can hold a list of available values (e.g. 0,1,2,3,4). The default list from 0 to 10 is used in case it is empty.", description_msgid='description_ilistobjectvalues', i18n_domain="plone"), ), )) class iCampFolio(OrderedBaseFolder): """ Folder for iCampTools """ meta_type = "iCampFolio" archetype_name = "iCampFolio" global_allow = 0 exclude_from_nav = False allowed_content_types = ('iCampTool') filter_content_types = True security = ClassSecurityInfo() _at_rename_after_creation = True schema = schema content_icon = 'icampfolio_icon.gif' actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/mainindex_view', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'permissions': ('Manage Portal',), }, ) right_slots = () # This fucntion is not used in Prototype one #(meant to be used for returning an array generated from the values in the text field) def getValuesAsArray(self): """ array of values """ arrayOfValues = str(self.getiCharr()).replace("\r","") arrayOfValues = arrayOfValues.split("\n") arrayOfReturned = [] for item in arrayOfValues: element = item.split(",") if len(element)>1: arrayOfReturned.append({'title':element[0],'maximum':element[1]}) return arrayOfReturned # This method dynamically sends all data of "numeric" fields to Java (see - "ontofilelist.txt"). def writeValuesIntoDataFile(self): """ sends values directly to Java """ iGeneralDataHolder = "\tlinks" objs = self.objectValues('iCampTool') if len(objs)>0: obj = objs[0] fields = obj.Schemata()['numeric'].fields() for x in fields: iGeneralDataHolder += '\t'+x.widget.Label(obj) iGeneralDataHolder += '\n' for obj in objs: iObjectDataLine = obj.Title() iObjectDataLine += '\t'+obj.absolute_url() for field in fields: iObjectDataLine += '\t'+field.get(obj) iObjectDataLine += '\n' iGeneralDataHolder += iObjectDataLine return iGeneralDataHolder registerType(iCampFolio, PROJECT_NAME)