data = '' security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit short object" return self.input_text('data', self.data) security.declareProtected('View', 'view') def view(self): "Inline draw view" url = self.data if url.count('<dtml'): url = self.gen_html(url) container = self.getCompoundDocContainer() if not url.count('://'): try: url = container.restrictedTraverse(url).absolute_url() except KeyError: url = container.absolute_url() return self.REQUEST.RESPONSE.redirect(url) security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "This is the basic search function" return self.data Globals.InitializeClass(UrlRedirect) import register register.registerClass(UrlRedirect)
dropDownPath, loadText, enableLoadButton = self.drawDropDownPathControls(documents, dropDownScript, **kw) if dropDownPath: temp.append(dropDownPath) else: temp.append(self.drawPrimaryDropDown(documents)) temp.append(self.drawAlternateDropDown(documents)) if loadText is None: loadText = 'Load Document' if enableLoadButton: temp.append(self.submitChanges(loadText)) return ''.join(temp) security.declarePrivate('drawPrimaryDropDown') def drawPrimaryDropDown(self, docs): "draw the primary drop down" js = 'onchange="submit()"' seq = [(name, name) for (name, i) in docs] seq.insert(0, ('', 'Load Document') ) return self.option_select(seq, 'selectedDocument', dataType='list:ignore_empty', events=js) security.declarePrivate('drawAlternateDropDown') def drawAlternateDropDown(self, docs): "draw the alternate drop down" return '' Globals.InitializeClass(ObjectCompoundController) import register register.registerClass(ObjectCompoundController)
updateReplaceList = ('name', ) configurable = ('name', ) security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit short object" return '<p>%s:%s</p>' % (self.getConfig('name'), self.true_false('data', self.data, 0)) security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.data security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: self.setObject('data', bool(int(string))) except ValueError: pass Globals.InitializeClass(ActionRadio) import register register.registerClass(ActionRadio)
# -*- coding: utf-8 -*- import datafilter #For Security control and init from AccessControl import ClassSecurityInfo import Globals class HTMLDataFilter(datafilter.DataFilter): "HTMLDataFilter apply this to an a list of dicts to make it output a table" meta_type = "HTMLDataFilter" security = ClassSecurityInfo() security.declareProtected('View', 'view') def view(self, archive=None, order=None, start=None, stop=None, header=1, query=None, merge=None): "Inline draw view" if order is None: order = self.getFieldOrder() records = self.getDataRecords(order, archive=archive, start=start, stop=stop, header=header, query=query, merge=merge) output = self.createTable(records) if output: return output else: return '<p>No Drawable Data Found</p>' Globals.InitializeClass(HTMLDataFilter) import register register.registerClass(HTMLDataFilter)
security.declareProtected('Python Record Modification', 'clear') def clear(self): "clear the OOBTree" self.setObject('records', None) self.setObject('recordsLength', None) security.declarePrivate("PrincipiaSearchSource") def PrincipiaSearchSource(self): "This is the basic search function" return '' security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.createBTreeLength() security.declarePrivate('createBTreeLength') def createBTreeLength(self): "remove Filters that are not being used" if self.records is not None: length = BTrees.Length.Length() length.set(len(self.records)) self.setObject('recordsLength', length) createBTreeLength = utility.upgradeLimit(createBTreeLength, 165) Globals.InitializeClass(LookupTable) import register register.registerClass(LookupTable)
"hold the freight class for this object it contains the class and the price" security = ClassSecurityInfo() meta_type = "FreightClass" freightClass = '' security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit short object" temp = [] temp.append('<p>') temp.append(self.freightClass) temp.append(self.price.edit()) temp.append('</p>') return ''.join(temp) security.declarePrivate('editOutput') def editOutput(self): "return a structure that another object can use to render the information relevent to this document" return [self.freightClass, self.price.edit()] security.declarePrivate('instance') instance = (('price', ('create', 'Money')), ) Globals.InitializeClass(FreightClass) import register register.registerClass(FreightClass)
data = [('echo_id', userName), ('merchant_pin', self.password), ('allow_duplicates', 'n'), ('batch_file', batch)] req = urllib2.Request( 'https://wwws.echo-inc.com/echonlinebatch/upload.asp', data) result = urllib2.urlopen(req).read() if self.validEchoSubmission(result): self.markProcessedOrders(orders) return result def validEchoSubmission(self, result): "check if this is a valid echo result for a submission so we can mark the orders as processed" #This is the first line that is sent for a valid transmission so lets check for that return result.startswith('Filename,Records,Bytes,BatchId,TraceFile') def validEchoResponse(self, response): "check if this is a valid echo result for a submission so we can mark the orders as processed" #This is the first line that is sent for a valid transmission so lets check for that return response.startswith( 'ID,Date,Time,TC,ECHO-ID,PAN,ExpDt,Amount,Status,AuthOrErr,AvsStatus,OrderNumber,Line,TraceCode' ) def validECHOTransaction(self, result): "check that we have a valid transaction to query echo for to get the results of the first submission" #This is the first line that is sent for a valid transmission so lets check for that return result.startswith('Filename,Records,Bytes,BatchId,TraceFile') Globals.InitializeClass(CreditCardECHO) import register register.registerClass(CreditCardECHO)
self.setRows(temp) security.declarePrivate('setRows') def setRows(self, table): "set the table to be this list of lists" self.setObject('table', table) security.declarePrivate('getRows') def getRows(self): "get all the rows of this document" if self.table is not None: return self.table return [[]] security.declareProtected('View', 'view') def view(self): "Render page" return self.createTable(self.getRows()) classConfig = {} classConfig['cols'] = {'name':'How many columns?', 'type':'int'} security.declarePrivate("PrincipiaSearchSource") def PrincipiaSearchSource(self): "This is the basic search function" return '' Globals.InitializeClass(SimpleTable) import register register.registerClass(SimpleTable)
if config.hasObject('meta_type') and config.meta_type == 'Config': config = config.convertToDict() replaceEntries = [key for key in config if key not in self.configKeep] for key in replaceEntries: self.setObject(key, config[key]) security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.data.replace('\n', '\\n') security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" self.setObject('data', string.replace('\\n', '\n')) self.updateCache() security.declareProtected('Change CompoundDoc', 'store') def store(self, string): "set the calculation value of this object" self.setObject('data', str(string)) self.updateCache() Globals.InitializeClass(TextArea) import register register.registerClass(TextArea)
if folder is not None: for i in folder.objectValues('CompoundDoc'): if i is not cdoc: temp.append( self.embedRemoteObject(i, path, mymode, view, profile, drawid)) return ''.join(temp) security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.removeRandomId() security.declarePrivate('makeDataASequence') def removeRandomId(self): "remove the randomId and stick timestamp in autotype if randomId is set" if self.randomId: self.setObject('autoType', 'timestamp') self.delObjects([ 'randomId', ]) removeRandomId = utility.upgradeLimit(removeRandomId, 160) Globals.InitializeClass(ContainerCompoundController) import register register.registerClass(ContainerCompoundController)
security.declareProtected('View', 'drawReport') def drawReport(self): "return the report of how the votes went" temp = [] if getSecurityManager().checkPermission('CompoundDoc: Voting', self): if self.checkDrawReport(): for i in self: temp.append(i.drawReport()) return ''.join(temp) def checkDrawReport(self): "check if it is okay to draw the voting report" if len(self): if self.voteMode in ('poll', 'simple'): return True if self.voteMode == 'vote' and not self.voteEnabled: return True return False security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" return None Globals.InitializeClass(Ballot) import register register.registerClass(Ballot)
def edit(self, *args, **kw): """This is the edit dispatcher. It should dispatch to the appropriate object edit view.""" return '<p>%s: %s</p>\n' % (self.title_or_id().capitalize(), self.input_text('data', self.data)) security.declareProtected('View management screens', 'config') def config(self): "return the configuration for this object which is just editing the title" return '<p>%s %s: %s</p>\n' % ('Title of ', self.getId(), self.input_text('title', self.data)) security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.data.replace('\n', '\\n') security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" self.setObject('data', string.replace('\\n', '\n')) Globals.InitializeClass(AttributeText) import register register.registerClass(AttributeText)
security.declarePrivate('createDataLoader') def createDataLoader(self): "return the data needed to rebuild this object as a dictionary that it can then take back to restore its information" return {'data': self.data} security.declarePrivate('dataLoader') def dataLoader(self, dict): "load the data from this dict into this object" if 'data' in dict: self.setObject('data', dict['data']) security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.data.replace('\n','\\n') security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" self.setObject('data',string.replace('\\n','\n')) security.declareProtected('Change CompoundDoc', 'store') def store(self, string): "set the calculation value of this object" self.setObject('data',str(string)) Globals.InitializeClass(InputText) import register register.registerClass(InputText)
if date: return str(date) return "" security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.Date() security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.getDate() security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: if string: self.setObject('data', DateTime.DateTime(string)) except ValueError: pass Globals.InitializeClass(Date) import register register.registerClass(Date)
calculated.setCalculationValue(calculator.calculate(self)) paths = [i.getPhysicalPath() for i in self.objectValues(self.creationType)] for id in calculatorcontainer.objectOrder: traversedObject = getattr(calculatorcontainer, id).getTraversedObject(self) if traversedObject is not None and traversedObject.getPhysicalPath() not in paths: traversedObject.observerAttached(self) security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit view" temp = [] format = "<p>ID: %s %s</p>" if self.calculatorPath: calculatorContainer = self.getRemoteObject(self.calculatorPath, 'CalculatorContainer') if calculatorContainer is not None: for id in calculatorContainer.objectOrder: object = getattr(self, id, None) if object is not None: temp.append(format % (object.getId(), object.edit())) return ''.join(temp) security.declarePrivate('eventProfileLast') def eventProfileLast(self): "run this event as the last thing the object will do before the profile is returned" self.delObjects([id for id in self.objectIds(self.creationType)]+['observed']) self.observerUpdate() Globals.InitializeClass(CalculatorWatcher) import register register.registerClass(CalculatorWatcher)
from userobject import UserObject class ScriptTitleEmbed(UserObject): "Embed the title from a python script object" security = ClassSecurityInfo() meta_type = "ScriptTitleEmbed" security.declareProtected('View management screens', 'edit') def edit(self, script=None, *args, **kw): "Inline edit short object" if script is not None and script.meta_type =='Script (Python)': path = '/'.join(script.getPhysicalPath()) return self.input_text('title', script.title, containers=['embedded',path]) else: return 'This object only works on Script (Python)' security.declarePrivate('after_manage_edit') def after_manage_edit(self, form): "Call this function after the editing has been processed so that additional things can be done like caching" if 'embedded' in form: for path, value in form['embedded'].iteritems(): script = self.restrictedTraverse(path, None) if script is not None: script.ZPythonScript_setTitle(value['title']) Globals.InitializeClass(ScriptTitleEmbed) import register register.registerClass(ScriptTitleEmbed)
security.declarePrivate('ammountMultiply') def ammountMultiply(self, remote): "multiply the item by this ammount" return self.getTraversedObjectValue(remote) * self.ammount security.declarePrivate('getTraversedObjectValue') def getTraversedObjectValue(self, remote): "return the floating point value of the returned object" object = self.getTraversedObject(remote) if object is None: return 0.0 if object.hasObject('float'): return object.float() elif callable(object): return float(object()) else: return float(object) security.declarePrivate('getTraversedObject') def getTraversedObject(self, remote): "get the remote object and return it" if not self.objectPath: return None object = remote.restrictedTraverse(self.objectPath) if object is not None: return object Globals.InitializeClass(Calculator) import register register.registerClass(Calculator)
#just seeing if that image exists self.image.image return True except AttributeError: return False security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.save_pic_url() security.declarePrivate('save_pic_url') def save_pic_url(self): "put the picture url in the imagefilter so we don't have to load a picture to draw an imagefilter" if self.scriptChangePath: #if we have a notification script the only way we can update our data is to run it self.REQUEST.other['UpdateCacheOnly'] = 1 self.runChangeNotificationScript() del self.REQUEST.other['UpdateCacheOnly'] else: self.updateImageSrcCache() self.delObjects(['imagesrc']) save_pic_url = utility.upgradeLimit(save_pic_url, 176) Globals.InitializeClass(ImageFilter) import register register.registerClass(ImageFilter)
def edit(self, *args, **kw): "Inline edit short object" temp = [] if self.calculated is not None: temp.append(str(self.calculated)) temp.append(self.input_float('data', self.data)) return ''.join(temp) security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.float() security.declareProtected('Change CompoundDoc', 'setCalculationValue') def setCalculationValue(self, value): "set the calculation value of this object" if value and isinstance(value, types.FloatType): self.setObject('calculated', value) security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: self.setObject('data', float(string)) except ValueError: pass Globals.InitializeClass(InputFloat) import register register.registerClass(InputFloat)
temp.append(self.editSingleConfig('renderer')) temp.append(NestedListURL.editRenderer(self.renderer, self)) temp.append(self.editSingleConfig('baseURL')) temp.append(self.editSingleConfig('depth')) temp.append(self.editSingleConfig('sortOn')) temp.append(self.editSingleConfig('folderSortOn')) temp.append(self.editSingleConfig('showCompoundDocs')) temp.append(self.editSingleConfig('restrictedMode')) temp.append(self.editSingleConfig('renderScriptPath')) temp.append(self.editSingleConfig('mergeScriptName')) temp.append(self.editSingleConfig('docsAsNodes')) profiles = [''] profiles.extend(utility.getStoredProfileNames()) selected = self.getSelected() temp.append('<p>%s</p>' % self.create_button('clear', 'Clear Selected Profile')) temp.append('<p>Profiles that are allowed:%s</p>' % self.multiselect('selected', profiles, selected, size=10)) return ''.join(temp) security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "Return what can be search which is nothing" return '' Globals.InitializeClass(ContainerTraverse) import register register.registerClass(ContainerTraverse)
if self.storage is None: self.storage = OOBTree() if not self.storage.has_key(uid): self.storage[uid] = True security.declarePrivate("choiceSelected") def choiceSelected(self, choices): "increment the counter for this choice" if self.votes is None: self.votes = OOBTree() lookup = {} lookup["choices"] = choices self.writeErrorMessage(self.getMessage("thankYouText", lookup), "thankYouText") for choice in choices: count = self.votes.get(choice, 0) count += 1 self.votes[choice] = count security.declarePrivate("classUpgrader") def classUpgrader(self): "upgrade this class" return None Globals.InitializeClass(Issue) import register register.registerClass(Issue)
doc = self.getSelectedDocument() selected = None if doc is not None: selected = [doc.getId()] temp.append(self.option_select(objects, 'delName', selected=selected)) temp.append(self.create_button('del', 'Delete %s' % self.typeStored)) return temp security.declarePrivate('getJSMenu') def getJSMenu(self, documents): "return the javascript menu for these documents" numberOfDocuments = len(documents) format = '%s/%s %s' seq = [(name, format % (index+1, numberOfDocuments, name)) for index, (name, i) in enumerate(documents)] seq.insert(0, ('jump', 'Jump To Document') ) temp = [self.option_select(seq, 'jump', selected=['jump'], events='onchange="jumpTo(this)"')] return ''.join(temp) security.declarePrivate('sortObjects') def sortObjects(self, objects, **kw): "sort these objects based on the sorton attribute" sorton = kw.get('sorton', None) if sorton: objects.sort(key=operator.attrgetter(sorton)) objects.sort() Globals.InitializeClass(ObjectsController) import register register.registerClass(ObjectsController)
def isOrderProcessed(self, order): "has this order been processed?" return getattr(order, self.processedVar).checked() def isOrderComplete(self, order): "is this order complete?" return self.isOrderProcessed( order) and order.profile == '' and order.total() def markProcessedOrders(self, orders): "mark these orders as processed so they are not run again" processedVarName = self.processedVar for order in orders: getattr(order, processedVarName).setObject('data', 1) def markOkayOrdersIds(self, orders): "mark these orders as okay/cleared so that we can do other stuff with them" processedOkayVar = self.processedOkayVar orderObjects = [] orderFolder = self.unrestrictedTraverse(self.ordersLocation, None) for orderId in orders: order = getattr(orderFolder, orderId) orderObjects.append(order) getattr(order, processedOkayVar).setObject('data', 1) return orderObjects Globals.InitializeClass(CreditCardManager) import register register.registerClass(CreditCardManager)
from AccessControl import ClassSecurityInfo import Globals from userobject import UserObject class IssueChoice(UserObject): "this object represents a choice within an issue" security = ClassSecurityInfo() meta_type = "IssueChoice" data = '' security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit short object" return '<p>Choice Text: %s</p>' % self.editDataStructure() security.declarePrivate('editDataStructure') def editDataStructure(self): "return a data structure that contains what is needed to edit this object instead of a string" return self.input_text('data', self.data) security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.data Globals.InitializeClass(IssueChoice) import register register.registerClass(IssueChoice)
security.declarePrivate('getTraversedObjectValue') def getTraversedObjectValue(self, remote): "return the floating point value of the returned object" object = self.getTraversedObject(remote) if object is None: return 0.0 if object.hasObject('float'): return object.float() elif callable(object): return float(object()) else: return float(object) security.declarePrivate('getTraversedObject') def getTraversedObject(self, remote): "get the remote object and return it" if not self.objectPath: return None object = remote.restrictedTraverse(self.objectPath) if object is not None: return object Globals.InitializeClass(Calculator) import register register.registerClass(Calculator)
import baseobject #For Security control and init from AccessControl import ClassSecurityInfo import Globals class CatalogConfig(baseobject.BaseObject): "CatalogConfig tracks how this objects work with different Catalogs" """This object is now obsolete and when the CatalogManager is updated it will take the data it needs and then delete the CatalogConfig objects it has""" meta_type = "CatalogConfig" security = ClassSecurityInfo() overwrite=1 useCatalog = '' Globals.InitializeClass(CatalogConfig) import register register.registerClass(CatalogConfig)
if self.storage is None: self.storage = OOBTree() if not self.storage.has_key(uid): self.storage[uid] = True security.declarePrivate('choiceSelected') def choiceSelected(self, choices): "increment the counter for this choice" if self.votes is None: self.votes = OOBTree() lookup = {} lookup['choices'] = choices self.writeErrorMessage(self.getMessage('thankYouText', lookup), 'thankYouText') for choice in choices: count = self.votes.get(choice, 0) count += 1 self.votes[choice] = count security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" return None Globals.InitializeClass(Issue) import register register.registerClass(Issue)
#This software is released under GNU public license. See details in the URL: #http://www.gnu.org/copyleft/gpl.html #For Security control and init from AccessControl import ClassSecurityInfo import Globals from userobject import UserObject class WatchDog(UserObject): """WatchDog class This class is designed to monitor other objects and keep information about who changed it and when etc.""" security = ClassSecurityInfo() meta_type = "WatchDog" security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class which is to delete it" self.getCompoundDoc().delObjects([self.getId()]) Globals.InitializeClass(WatchDog) import register register.registerClass(WatchDog)
security.declarePrivate('getDate') def getDate(self): "Return the date object if possible as a string" date = self.Date() if date: return str(date) return "" security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.Date() security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return self.getDate() security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: if string: self.setObject('data',DateTime.DateTime(string)) except ValueError: pass Globals.InitializeClass(Date) import register register.registerClass(Date)
import baseobject # For Security control and init from AccessControl import ClassSecurityInfo import Globals class CatalogConfig(baseobject.BaseObject): "CatalogConfig tracks how this objects work with different Catalogs" """This object is now obsolete and when the CatalogManager is updated it will take the data it needs and then delete the CatalogConfig objects it has""" meta_type = "CatalogConfig" security = ClassSecurityInfo() overwrite = 1 useCatalog = "" Globals.InitializeClass(CatalogConfig) import register register.registerClass(CatalogConfig)
temp.extend((object.edit() for name,object in seq)) return ''.join(temp) security.declarePrivate('genFreightCompanyListings') def genFreightCompanyListings(self): "generate the freight company listing dict" listing = {} for company in self.objectValues('FreightCompany'): listing.update(company.getFreightCompanyListing()) self.setObject('listing', listing) security.declarePrivate('getAllFreightCompanyListings') def getAllFreightCompanyListings(self): "return the listing for all the freight companies" if not self.hasObject('listing'): self.genFreightCompanyListings() return self.listing security.declarePrivate('eventProfileLast') def eventProfileLast(self): "run this event as the last thing the object will do before the profile is returned" object = self.getRemoteObject(self.freightCompanyCreatorPath, 'FreightCompanyCreator') if object is not None: self.observerUpdate() self.genFreightCompanyListings() object.observerAttached(self) Globals.InitializeClass(FreightCompanyWatcher) import register register.registerClass(FreightCompanyWatcher)
import Globals import utility from baseevent import BaseEvent class EventManager(base.Base): "EventManager manages all Events" meta_type = "EventManager" security = ClassSecurityInfo() overwrite=1 security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit view" temp = [] temp.append('<div class="outline">') for i in self.getAllEvents(): temp.append(i.edit()) temp.append("</div>") return ''.join(temp) security.declarePrivate("getAllEvents") def getAllEvents(self): "Return a list of all items that are a BaseEvent" return [object for object in self.objectValues() if utility.isinstance(object, BaseEvent)] Globals.InitializeClass(EventManager) import register register.registerClass(EventManager)
batch = StringIO.StringIO(batch) batch.name = '%s.csv' % repr(time.time()).replace('.', '_') data = [ ('echo_id', userName), ('merchant_pin',self.password), ('allow_duplicates','n'), ('batch_file',batch)] req = urllib2.Request('https://wwws.echo-inc.com/echonlinebatch/upload.asp', data) result = urllib2.urlopen(req).read() if self.validEchoSubmission(result): self.markProcessedOrders(orders) return result def validEchoSubmission(self,result): "check if this is a valid echo result for a submission so we can mark the orders as processed" #This is the first line that is sent for a valid transmission so lets check for that return result.startswith('Filename,Records,Bytes,BatchId,TraceFile') def validEchoResponse(self,response): "check if this is a valid echo result for a submission so we can mark the orders as processed" #This is the first line that is sent for a valid transmission so lets check for that return response.startswith('ID,Date,Time,TC,ECHO-ID,PAN,ExpDt,Amount,Status,AuthOrErr,AvsStatus,OrderNumber,Line,TraceCode') def validECHOTransaction(self,result): "check that we have a valid transaction to query echo for to get the results of the first submission" #This is the first line that is sent for a valid transmission so lets check for that return result.startswith('Filename,Records,Bytes,BatchId,TraceFile') Globals.InitializeClass(CreditCardECHO) import register register.registerClass(CreditCardECHO)
return ''.join(temp) security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.unorderedList(self.getEntries()) security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "This is the basic search function" return ' '.join(self.getEntries()) security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.convertListToOOTreeSet() security.declarePrivate('convertListToOOTreeSet') def convertListToOOTreeSet(self): "conver the list object to an OOTreeSet" if len(self.entry) and isinstance(self.entry, types.ListType): temp = OOTreeSet() for i in self.entry: temp.insert(i) self.setObject('entry', temp) convertListToOOTreeSet = utility.upgradeLimit(convertListToOOTreeSet, 141) Globals.InitializeClass(SimpleList) import register register.registerClass(SimpleList)
available = [''] + self.aq_parent.availableObjects() temp = [] temp.append('<p>Object Type:%s</p>' % self.option_select(available, 'metaType', [self.metaType])) typeformat = '<p>Id: %s Type:%s</p>' available = [''] + self.availableObjects() if self.idTypeMapping is not None: for i, j in self.idTypeMapping.items(): temp.append( typeformat % (self.input_text(i, i, containers=('idTypeMapping', )), self.option_select( available, i, [j], containers=('idTypeMapping', )))) temp.append(typeformat % (self.input_text('idTypeMappingNew'), self.option_select(available, 'idTypeMappingNew'))) return ''.join(temp) security.declarePrivate('setupObject') def setupObject(self, object): "if this object is the kind we are looking for create the other items we need in it" if self.idTypeMapping is not None and object.meta_type == self.metaType: for id, type in self.idTypeMapping.items(): object.updateRegisteredObject(id, type) Globals.InitializeClass(CreationAssistant) import register register.registerClass(CreationAssistant)
def createDataLoader(self): "return the data needed to rebuild this object as a dictionary that it can then take back to restore its information" return {'data': self.data} security.declarePrivate('dataLoader') def dataLoader(self, dict): "load the data from this dict into this object" if 'data' in dict: self.setObject('data', dict['data']) security.declareProtected('Python Record Addition', 'setDataStructure') def setDataStructure(self, data): "set a data structure in this object" self.setObject('data', data) security.declareProtected('Change CompoundDoc', 'store') store = setDataStructure security.declareProtected('Python Record Addition', 'getDataStructure') def getDataStructure(self): "set a data structure in this object" return self.data Globals.InitializeClass(DataStructure) import register register.registerClass(DataStructure)
upgraderChangeTupleTreeAgent = utility.upgradeLimit(upgraderChangeTupleTreeAgent, 141) security.declarePrivate("upgraderFixAgents") def upgraderFixAgents(self): "Fix the useragent detection vars to use the newer DisplayUserAgent object" if self.hasObject("clients") and self.clients is not None: self.gen_vars() mapping = self.UserAgent.clientSetMapping() for key, value in mapping.items(): if key and value: mapping[key] = getattr(self.UserAgent, value)() else: del mapping[key] for setname, clients in mapping.items(): if self.clients == clients: self.UserAgent.setused = setname self.delObjects(["clients"]) break if self.hasObject("clients") and self.clients is not None: self.UserAgent.setClients(self.clients) self.delObjects(["clients"]) upgraderFixAgents = utility.upgradeLimit(upgraderFixAgents, 141) Globals.InitializeClass(DisplayFilter) import register register.registerClass(DisplayFilter)
listName = self.listName if listName: addresses = getattr(self.getCompoundDoc(), listName) message = '%s\r\n\r\n%s\r\n\r\n%s\r\n\r\n' % (self.header, self.message, self.footer) message = DTML(message) From = self.listFrom Subject = self.subject server = smtplib.SMTP(self.server) msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s") for address in addresses.getEntries(): message = message(self, self.REQUEST, address=address) server.sendmail(From, address, msg % (From, address, Subject, message)) server.quit() security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.fixFrom() security.declarePrivate('fixFrom') def fixFrom(self): "fix the from attribute" if 'from' in self.__dict__: self.listFrom = getattr(self, 'from') self.delObjects(['from']) fixFrom = utility.upgradeLimit(fixFrom, 141) Globals.InitializeClass(ListMailer) import register register.registerClass(ListMailer)
temp.append( '<p>Where is the shopping cart located? %s</p>' % self.input_text('pathToShoppingCart', self.pathToShoppingCart)) return ''.join(temp) security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "Return what can be search which is nothing" return '' security.declarePrivate('classUpgrader') def classUpgrader(self): "upgrade this class" self.removeSessionManagerConfig() security.declarePrivate('removeSessionManagerConfig') def removeSessionManagerConfig(self): "remove SessionManagerConfig" self.delObjects(['SessionManagerConfig']) removeSessionManagerConfig = utility.upgradeLimit( removeSessionManagerConfig, 156) Globals.InitializeClass(EComControl) import register register.registerClass(EComControl)
else: temp.append('%.2f' % currentPrice) return temp security.declarePrivate('calcRow') def calcRowBuy(self, seq, quantity, basePrice, ecom, func=None): prices = [] quantities = [] format = '<a href="%s/add?quantity=%s">%s</a>' ecomUrl = ecom.absolute_url() for percent,number in zip(seq,quantity): if percent is not None and number is not None: currentPrice = (basePrice*(100-percent))/100 if currentPrice > 0: stringPrice = '%.2f' % currentPrice prices.append(format % (ecomUrl, number, stringPrice)) quantities.append(number) return [quantities, prices] security.declarePrivate('instance') instance = (('SessionManagerConfig', ('create', 'SessionManagerConfig')),) security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "Return what can be search which is nothing" return '' Globals.InitializeClass(TableEcom) import register register.registerClass(TableEcom)
def setCalculationValue(self, value): "set the calculation value of this object" if value and isinstance(value, types.FloatType): self.setObject('calculated', value) security.declarePrivate('populatorInformation') def populatorInformation(self): "return a string that this metods pair can read back to load data in this object" return '%.2f' % self.data security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: self.setObject('data', float(string)) except ValueError: pass security.declareProtected('Change CompoundDoc', 'store') def store(self, value): "set the calculation value of this object" self.populatorLoader(value) Globals.InitializeClass(Money) import register register.registerClass(Money)
length = BTrees.Length.Length() length.set(len(self.records)) self.setObject('recordsLength', length) if self.archive is not None: length = BTrees.Length.Length() length.set(len(self.archive)) self.setObject('archiveLength', length) createBTreeLength = utility.upgradeLimit(createBTreeLength, 164) security.declarePrivate('convertDictToPersistentMapping') def convertDictToPersistentMapping(self): "convert the dictionaries we have stored to persistent mapping so they can be deactivated" if self.records is not None: for key, value in com.db.subTrans(self.records.items(), 500): self.records[key] = persistent.mapping.PersistentMapping(value) if self.archive is not None: for key, value in com.db.subTrans(self.archive.items(), 500): self.archive[key] = persistent.mapping.PersistentMapping(value) convertDictToPersistentMapping = utility.upgradeLimit( convertDictToPersistentMapping, 167) Globals.InitializeClass(DataRecorder) import register register.registerClass(DataRecorder)
security = ClassSecurityInfo() meta_type = "FreightCompanyCreator" security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit short object" temp = [] temp.append('<p>Freight Companies</p>') temp.append(self.freightCompanies.edit()) temp.append('<p>Freight Classes</p>') temp.append(self.freightClasses.edit()) return ''.join(temp) security.declarePrivate('instance') instance = (('freightCompanies', ('create', 'ListText')),('freightClasses',('create', 'ListText'))) security.declarePrivate('getFreightCompanies') def getFreightCompanies(self): "return the freight companies that we have" return self.freightCompanies.getAvailableListsContents() security.declarePrivate('getFreightClasses') def getFreightClasses(self): "return the freight classes that we have" return self.freightClasses.getAvailableListsContents() Globals.InitializeClass(FreightCompanyCreator) import register register.registerClass(FreightCompanyCreator)
self.setObject("table", table) security.declarePrivate("getRows") def getRows(self): "get all the rows of this document" if self.table is not None: return self.table return [[]] security.declareProtected("View", "view") def view(self): "Render page" return self.createTable(self.getRows()) classConfig = {} classConfig["cols"] = {"name": "How many columns?", "type": "int"} security.declarePrivate("PrincipiaSearchSource") def PrincipiaSearchSource(self): "This is the basic search function" return "" Globals.InitializeClass(SimpleTable) import register register.registerClass(SimpleTable)
def edit(self, pageId=None, *args, **kw): "Inline edit short object" temp = [] if self.calculated is not None: temp.append(str(self.calculated)) temp.append(self.input_number('data', self.data, pageId=pageId)) return ''.join(temp) security.declareProtected('View', 'view') def view(self): "Inline draw view" return self.int() security.declareProtected('Change CompoundDoc', 'setCalculationValue') def setCalculationValue(self, value): "set the calculation value of this object" if value and isinstance(value, types.FloatType): self.setObject('calculated', int(value)) security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" try: self.setObject('data', int(string)) except ValueError: pass Globals.InitializeClass(InputInt) import register register.registerClass(InputInt)
security.declarePrivate('createBTreeLength') def createBTreeLength(self): "remove Filters that are not being used" if self.records is not None: length = BTrees.Length.Length() length.set(len(self.records)) self.setObject('recordsLength', length) if self.archive is not None: length = BTrees.Length.Length() length.set(len(self.archive)) self.setObject('archiveLength', length) createBTreeLength = utility.upgradeLimit(createBTreeLength, 164) security.declarePrivate('convertDictToPersistentMapping') def convertDictToPersistentMapping(self): "convert the dictionaries we have stored to persistent mapping so they can be deactivated" if self.records is not None: for key,value in com.db.subTrans(self.records.items(), 500): self.records[key] = persistent.mapping.PersistentMapping(value) if self.archive is not None: for key,value in com.db.subTrans(self.archive.items(), 500): self.archive[key] = persistent.mapping.PersistentMapping(value) convertDictToPersistentMapping = utility.upgradeLimit(convertDictToPersistentMapping, 167) Globals.InitializeClass(DataRecorder) import register register.registerClass(DataRecorder)
"EventManager manages all Events" meta_type = "EventManager" security = ClassSecurityInfo() overwrite = 1 security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit view" temp = [] temp.append('<div class="outline">') for i in self.getAllEvents(): temp.append(i.edit()) temp.append("</div>") return ''.join(temp) security.declarePrivate("getAllEvents") def getAllEvents(self): "Return a list of all items that are a BaseEvent" return [ object for object in self.objectValues() if utility.isinstance(object, BaseEvent) ] Globals.InitializeClass(EventManager) import register register.registerClass(EventManager)
security = ClassSecurityInfo() meta_type = "FreightClass" freightClass = "" security.declareProtected("View management screens", "edit") def edit(self, *args, **kw): "Inline edit short object" temp = [] temp.append("<p>") temp.append(self.freightClass) temp.append(self.price.edit()) temp.append("</p>") return "".join(temp) security.declarePrivate("editOutput") def editOutput(self): "return a structure that another object can use to render the information relevent to this document" return [self.freightClass, self.price.edit()] security.declarePrivate("instance") instance = (("price", ("create", "Money")),) Globals.InitializeClass(FreightClass) import register register.registerClass(FreightClass)
"process the edits" allowedIds = dict.pop('allowedIds', None) if allowedIds is not None: formAllowedIds = allowedIds.split() if not len(formAllowedIds): formAllowedIds = None self.setObject('allowedIds',formAllowedIds) security.declareProtected('View management screens', 'edit') def edit(self, *args, **kw): "Inline edit view" return '<p>DTML string to run: %s </p><p>Allowed Object Ids: %s </p>' % ( self.input_text('dtmlstring', self.getDTMLString()), self.input_text('allowedIds', ' '.join(self.getAllowedIds()))) security.declarePrivate('getAllowedIds') def getAllowedIds(self): "Return all the allowed object ids" if self.allowedIds is not None: return self.allowedIds return [] security.declarePrivate('getDTMLString') def getDTMLString(self): "return the dtml string that can be run" return getattr(self, 'dtmlstring') Globals.InitializeClass(EventBlankDTML) import register register.registerClass(EventBlankDTML)
records = getattr(self, self.useCatalog)(meta_type='CompoundDoc') return [self.embedRemoteObject(cdoc, path, mymode, view, profile, drawid) for cdoc in com.catalog.catalogIter(records)] security.declarePrivate('PrincipiaSearchSource') def PrincipiaSearchSource(self): "This is the basic search function" return '' security.declareProtected('View', 'view') def view(self): "Inline draw view" mymode = self.viewMode view = self.viewName path = self.viewObjectPath profile = self.viewProfile drawid = self.viewId #Fast abort so we don't dispatch to a bunch of other methods for something that can't draw if mymode not in self.modes: return '' temp = [] for cdoc in com.catalog.catalogIter(getattr(self, self.useCatalog)(meta_type='CompoundDoc')): temp.append(self.embedRemoteObject(cdoc, path, mymode, view, profile, drawid)) return ''.join(temp) Globals.InitializeClass(CatalogCompoundController) import register register.registerClass(CatalogCompoundController)
"return a string that this metods pair can read back to load data in this object" return '%s /-\ %s' % (self.heading, self.data.replace('\n', '\\n')) security.declarePrivate('populatorLoader') def populatorLoader(self, string): "load the data into this object if it matches me" heading, data = string.split(' /-\ ', 1) self.setObject('data', data.replace('\\n', '\n')) self.setObject('heading', heading.replace('\\n', '\n')) self.updateCache() security.declarePrivate('removeAttributeText') def removeAttributeText(self): "remove the attributetext items and replace them with basic attributes" heading = self.heading.data self.delObjects(('heading',)) self.setObject('heading', heading) self.updateCache() removeAttributeText = utility.upgradeLimit(removeAttributeText, 149) security.declareProtected('Change CompoundDoc', 'store') def store(self, data, heading): "set the calculation value of this object" self.setObject('data',str(data)) self.setObject('heading', str(heading)) self.updateCache() Globals.InitializeClass(SectionText) import register register.registerClass(SectionText)
security.declarePrivate('createTreeFromDataSource') def createTreeFromDataSource(self, data): "create a zope tree structure based on a data source" try: folder = self.restrictedTraverse(self.startFolder) self.createDocuments(folder, data) except AttributeError: pass security.declareProtected('Change CompoundDoc', 'createDocuments') def createDocuments(self, folder, data): "create documents at this path using this data" if '\r\n' in data: data = data.replace('\r\n', '\n') entries = [entry.split('\n') for entry in data.split('\n\n\n')] pathEntries = [(entry[0].split(' ', 1), entry[1:]) for entry in entries] try: for (path, profile), entries in pathEntries: self.createCdocAtLocation(path, profile, folder, entries) except ValueError: #Catches when the data format is wrong pass self.getCompoundDoc().processChanges() Globals.InitializeClass(AutoPopulator) import register register.registerClass(AutoPopulator)
def view(self, archive=None, order=None, start=None, stop=None, header=1, query=None, merge=None): "Inline draw view" if order is None: order = self.getFieldOrder() records = self.getDataRecords(order, archive=archive, start=start, stop=stop, header=header, query=query, merge=merge) output = self.createTable(records) if output: return output else: return '<p>No Drawable Data Found</p>' Globals.InitializeClass(HTMLDataFilter) import register register.registerClass(HTMLDataFilter)
"<p>Where is the shopping cart located? %s</p>" % self.input_text("pathToShoppingCart", self.pathToShoppingCart) ) return "".join(temp) security.declarePrivate("PrincipiaSearchSource") def PrincipiaSearchSource(self): "Return what can be search which is nothing" return "" security.declarePrivate("classUpgrader") def classUpgrader(self): "upgrade this class" self.removeSessionManagerConfig() security.declarePrivate("removeSessionManagerConfig") def removeSessionManagerConfig(self): "remove SessionManagerConfig" self.delObjects(["SessionManagerConfig"]) removeSessionManagerConfig = utility.upgradeLimit(removeSessionManagerConfig, 156) Globals.InitializeClass(EComControl) import register register.registerClass(EComControl)
if deleted and self.meta_type == 'CreationAssistant': [i.delObjects(deleted) for i in self.aq_parent.objectValues(self.metaType)] security.declarePrivate('configAddition') def configAddition(self): "addendum to the default config screen" available =[''] + self.aq_parent.availableObjects() temp = [] temp.append('<p>Object Type:%s</p>' % self.option_select(available, 'metaType', [self.metaType])) typeformat = '<p>Id: %s Type:%s</p>' available =[''] + self.availableObjects() if self.idTypeMapping is not None: for i, j in self.idTypeMapping.items(): temp.append(typeformat % (self.input_text(i, i, containers=('idTypeMapping',)), self.option_select(available, i, [j], containers=('idTypeMapping',)))) temp.append(typeformat % (self.input_text('idTypeMappingNew'), self.option_select(available, 'idTypeMappingNew'))) return ''.join(temp) security.declarePrivate('setupObject') def setupObject(self, object): "if this object is the kind we are looking for create the other items we need in it" if self.idTypeMapping is not None and object.meta_type == self.metaType: for id, type in self.idTypeMapping.items(): object.updateRegisteredObject(id, type) Globals.InitializeClass(CreationAssistant) import register register.registerClass(CreationAssistant)
self.upgraderChangeDisplayObjectRef() self.removeOldVars() security.declarePrivate('removeOldVars') def removeOldVars(self): "remove some old variables" self.delObjects(['alias', 'registeredFilters']) removeOldVars = utility.upgradeLimit(removeOldVars, 141) security.declarePrivate('upgraderChangeDisplayObjectRef') def upgraderChangeDisplayObjectRef(self): "Change the object refs in default edit to a name instead" id = self.getId() default = 'defaultFilter' self.delObjects([id + 'edit']) try: self.setObject(default, getattr(self, default).getId()) except AttributeError: pass upgraderChangeDisplayObjectRef = utility.upgradeLimit( upgraderChangeDisplayObjectRef, 141) Globals.InitializeClass(Display) import register register.registerClass(Display)