Tip: Click lines to highlight, hold ctrl/cmd to multi-select
http://codedumper.com/ohafe (21-Aug @ 04:20)
Syntax Highlighted Code
- class AddEmaqsFromFile(form.AddForm):
- form_fields = form.Fields(IPortalRootEpochFolder)
- def createMyClientEntry(self, context, entry):
- name = entry[3]
- newentry = context[name] = IMyClientEntry()
- newentry.setEntry(entry)
- def getObjectCreationURI(self, entry, self.createMyClientEntry):
- uniquechannelid = entry[0] + entry[2]
- epoch_from_emaq_entry = float(entry[3])
- return [uniquechannelid] + fromEpochFolderNamer(epoch_from_emaq_entry)[:3]
- def objectExists(self, context, name):
- if name in context.containedObjects():
- return True
- else:
- return False
- def createObjectFromUri(self, context, uripath, entry):
- print context
- emaqdb = getParents(context)[-2]['emaqdb']
- allowed_channels = [item for item in emaqdb.keys()]
- context = context
- for element in uripath:
- index = 0 #this keeps track of where we're at in the uripath
- if self.objectExists(context, element) == False:
- if uripath[0] in allowed_channels and element != self.createMyClientEntry: # no unregistered emaqs allowed
- context[element] = EpochFolder()
- context = context[element] # should fail if there's a problem!
- index += 1
- else:
- context = context[element]
- index += 1
- index = 0
Plain Code
class AddEmaqsFromFile(form.AddForm):
form_fields = form.Fields(IPortalRootEpochFolder)
def createMyClientEntry(self, context, entry):
name = entry[3]
newentry = context[name] = IMyClientEntry()
newentry.setEntry(entry)
def getObjectCreationURI(self, entry, self.createMyClientEntry):
uniquechannelid = entry[0] + entry[2]
epoch_from_emaq_entry = float(entry[3])
return [uniquechannelid] + fromEpochFolderNamer(epoch_from_emaq_entry)[:3]
def objectExists(self, context, name):
if name in context.containedObjects():
return True
else:
return False
def createObjectFromUri(self, context, uripath, entry):
print context
emaqdb = getParents(context)[-2]['emaqdb']
allowed_channels = [item for item in emaqdb.keys()]
context = context
for element in uripath:
index = 0 #this keeps track of where we're at in the uripath
if self.objectExists(context, element) == False:
if uripath[0] in allowed_channels and element != self.createMyClientEntry: # no unregistered emaqs allowed
context[element] = EpochFolder()
context = context[element] # should fail if there's a problem!
index += 1
else:
context = context[element]
index += 1
index = 0