from OFS.Folder import Folder from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2 from Globals import Persistent, Acquisition from utils import cookString from zope.interface import implements import zope from zope.component import getUtility from ZPublisher.HTTPRequest import FileUpload from interfaces import IToolsManager, ITool, IAffordanceManager from Tool import Tool class ToolsManager(Persistent, Folder, Acquisition.Implicit): implements(IToolsManager) meta_type = 'ToolsManager' id = 'tools' def getTools(self): return self.objectValues('Tool') def getToolIds(self): return self.objectIds('Tool') def listTools(self): """ list tools for "Tools" tab. {'toolid': {'title':'Yahoo!', 'img'} } """ res = [] for t in self.getTools(): if t.getHasThumbnail(): turl = 'tools/'+t.id+'/getThumbnail' else: turl = '++resource++styles/tool_default.png' res.append({'id': t.id.encode('utf-8'), 'title': t.title.encode('utf-8'), 'img': turl}) return str(res).replace("'", '"') def newToolForm(self): """ new Tool adding form """ # general parameters left = '
' sch = zope.schema.getFields(ITool) # l.order # lres = [] for x in sch.keys(): f = sch.get(x) ltmp = "" ltmp += '
' ltmp += '
'+f.title.encode('utf-8')+"
" #ltmp += '
' ltmp += '
'+f.description.encode('utf-8')+"
" if 'TextLine' in str(f): ltmp += '
' elif 'Text' in str(f): ltmp += '