Tip: Click lines to highlight, hold ctrl/cmd to multi-select

http://codedumper.com/ohafe (21-Aug @ 04:20)

Syntax Highlighted Code

  1. class AddEmaqsFromFile(form.AddForm):
  2.    
  3.     form_fields = form.Fields(IPortalRootEpochFolder)
  4.    
  5.     def createMyClientEntry(self, context, entry):
  6.         name = entry[3]
  7.         newentry = context[name] = IMyClientEntry()
  8.         newentry.setEntry(entry)
  9.        
  10.     def getObjectCreationURI(self, entry, self.createMyClientEntry):
  11.         uniquechannelid = entry[0] + entry[2]
  12.         epoch_from_emaq_entry = float(entry[3])
  13.         return [uniquechannelid] + fromEpochFolderNamer(epoch_from_emaq_entry)[:3]
  14.    
  15.     def objectExists(self, context, name):
  16.         if name in context.containedObjects():
  17.             return True
  18.         else:
  19.             return False
  20.    
  21.     def createObjectFromUri(self, context, uripath, entry):
  22.         print context
  23.         emaqdb = getParents(context)[-2]['emaqdb']
  24.         allowed_channels = [item for item in emaqdb.keys()]
  25.         context = context
  26.         for element in uripath:
  27.             index = 0 #this keeps track of where we're at in the uripath
  28.             if self.objectExists(context, element) == False:
  29.                 if uripath[0] in allowed_channels and element != self.createMyClientEntry: # no unregistered emaqs allowed
  30.                     context[element] = EpochFolder()
  31.                     context = context[element] # should fail if there's a problem!
  32.                     index += 1
  33.             else:
  34.                 context = context[element]
  35.                 index += 1
  36.             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

Permalink: http://codedumper.com/ohafe