File:  [Repository] / OSAS / OSA_system / OSAS_addfiles.py
Revision 1.12: download - view: text, annotated - select for diffs - revision graph
Sun Oct 12 21:19:13 2003 UTC (20 years, 8 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
minor changes and sorfield

    1: # Methoden und Classen zum Hinzufuegen von Dokumenten
    2: 
    3: import xml.dom.minidom
    4: from Products.ECHO_content import ECHO_collection
    5: import urllib
    6: import OSAS_add
    7: import OSAS_show
    8: import string
    9: from OFS.Folder import Folder
   10: from AccessControl import ClassSecurityInfo
   11: from Globals import InitializeClass
   12: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
   13: from Products.PageTemplates.PageTemplate import PageTemplate
   14: 
   15: class OSAS_add_Document(Folder):
   16:     """Hinzufuegen eines Dokumentes zum Storage"""
   17:     security=ClassSecurityInfo()
   18: 
   19:     def __init__(self,id):
   20:         """initialize a new instance"""
   21:         self.id = id
   22:         
   23:         
   24:     meta_type='OSAS_add_Document'    
   25:     manage_options = Folder.manage_options+(
   26:             {'label':'Main Config','action':'add_Document_config'},
   27:             )
   28:         
   29:      
   30:         
   31:     security.declarePublic('add_Document_config')
   32:     def add_Document_config(self):
   33:         """Main configuration"""
   34:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_addDocument.zpt').__of__(self)
   35:         return pt()
   36:     
   37:     security.declarePublic('change_OSAS_add_Document')
   38:     def change_OSAS_add_Document(self,RESPONSE=None):
   39:         """Change"""
   40: #        self.RootFolderName=RootFolderName
   41:         if RESPONSE is not None:
   42:             RESPONSE.redirect('manage_main')
   43: 
   44:     security.declarePublic('index_html')
   45:     def index_html(self):
   46:         """stantard aufruf"""
   47:         return OSAS_add.add(self,no_upload=1)
   48: 
   49: 
   50:     security.declarePublic('add2')
   51:     def add2(self):
   52:         """ anlegen naechster schritt"""
   53:         return OSAS_add.add2(self)
   54: 
   55:     def add3(self):
   56:         """Foldername"""
   57:         return OSAS_add.add3(self)
   58: 
   59:     def add4(self):
   60:         """Applet"""
   61:         return OSAS_add.add4(self)
   62: 
   63:     def add5(self):
   64:         """Foldername"""
   65:         return OSAS_add.add5(self)
   66: 
   67:     def add6(self):
   68:         """write new index.meta file"""
   69:         return OSAS_add.add6(self)
   70: 
   71: 
   72:     def addImages(self,path):
   73:         """Hinzufügen eines neuen Imagesfolders"""
   74:         return OSAS_add.addImages(self,path)
   75: 
   76:     def addImages2(self):
   77:         """Upload des neuen Imagefolders"""
   78:         return OSAS_add.addImages2(self)
   79: 
   80:     
   81: def manage_AddOSAS_add_DocumentForm(self):
   82:     """interface for adding the OSAS_add_Metadata"""
   83:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_document.zpt').__of__(self)
   84:     return pt()
   85: 
   86: def manage_AddOSAS_add_Document(self,id,RESPONSE=None):
   87:     """add the OSAS_root"""
   88:     newObj=OSAS_add_Document(id)
   89:     self.Destination()._setObject(id,newObj)
   90:     if RESPONSE is not None:
   91:         RESPONSE.redirect('manage_main')
   92: 
   93:             
   94: InitializeClass(OSAS_add_Document)
   95: 
   96: 
   97: class OSAS_add_Text(Folder):
   98:     """Hinzufuegen eines Text-Dokumentes zum Storage"""
   99:     security=ClassSecurityInfo()
  100: 
  101:     def __init__(self,id):
  102:         """initialize a new instance"""
  103:         self.id = id
  104:         
  105:         
  106:     meta_type='OSAS_add_Text'    
  107:     manage_options = Folder.manage_options+(
  108:             {'label':'Main Config','action':'add_Text_config'},
  109:             )
  110:         
  111:      
  112:         
  113:     security.declarePublic('add_Text_config')
  114:     def add_Text_config(self):
  115:         """Main configuration"""
  116:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_addText.zpt').__of__(self)
  117:         return pt()
  118:     
  119:     security.declarePublic('change_OSAS_add_Text')
  120:     def change_OSAS_add_Text(self,RESPONSE=None):
  121:         """Change"""
  122: #        self.RootFolderName=RootFolderName
  123:         if RESPONSE is not None:
  124:             RESPONSE.redirect('manage_main')
  125: 
  126:     def addText(self,path):
  127:         """Add a fulltext"""
  128:         return OSAS_add.addText(self,path)
  129: 
  130:     def addText2(self):
  131:         """Read the file and store it"""
  132:         return OSAS_add.addText2(self)
  133: def manage_AddOSAS_add_TextForm(self):
  134:     """interface for adding the OSAS_add_Metadata"""
  135:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_text.zpt').__of__(self)
  136:     return pt()
  137: 
  138: def manage_AddOSAS_add_Text(self,id,RESPONSE=None):
  139:     """add the OSAS_root"""
  140:     newObj=OSAS_add_Text(id)
  141:     self.Destination()._setObject(id,newObj)
  142:     if RESPONSE is not None:
  143:         RESPONSE.redirect('manage_main')
  144: 
  145:             
  146: InitializeClass(OSAS_add_Text)
  147: 
  148: class OSAS_add_contextData(Folder):
  149:     """Einfuegen eines Documentes in eine Collection"""
  150:     
  151:     security=ClassSecurityInfo()
  152: 
  153:             
  154:     meta_type='OSAS_add_contextData'    
  155: 
  156:     def __init__(self,id,collection):
  157:         self.id=id
  158:         self.collection=collection
  159: 
  160:     def getChilds(self,id,depth,items):
  161:         list=[]
  162:         for object in items:
  163:             if (depth==object[2])&(id==object[0]):
  164:                 list.append(object)
  165:         return list
  166: 
  167:     def printChilds(self,startItem,depth,items,enddepth):
  168: 
  169:         def spaces(depth):
  170:             tmp=""
  171:             k=0
  172:             while k<2*depth:
  173:                 k+=1
  174:                 tmp=tmp+"&nbsp;"+"&nbsp;"
  175:             return tmp
  176: 
  177:         def retLink(object):
  178:             return "<input type='checkbox' name='collection' value='%s'>%s</input>"% (string.join(object.getPhysicalPath(),"."),object.title)
  179:              
  180:         depth+=1
  181:         childs=self.getChilds(startItem,depth,items)
  182:         tmp=""
  183:         for child in childs:
  184:             if depth < enddepth:
  185:                 tmp=tmp+spaces(depth)
  186:                 
  187:                 tmp= tmp+retLink(child[1])+"<br>"+self.printChilds(child[1],depth,items,enddepth)
  188:             else:
  189:                 tmp=tmp+spaces(2*depth)
  190:                 tmp = tmp+retLink(child[1])
  191: 
  192:         return tmp
  193:                     
  194:     def generateTree(self,depth=10):
  195:         """Erzeugt HTML-Tree der Collection"""
  196:     
  197:         exec("items=self.getPhysicalRoot()."+self.collection+".getCollectionTree()")
  198:         #print items[0][0]
  199: 
  200:         childs=self.printChilds(items[0][0],0,items,depth)
  201:         
  202:         return childs
  203: 
  204:     def getPartners(self):
  205:         """Zeige Partnerliste"""
  206:         exec("items=self.getPhysicalRoot()."+self.collection+".partners.getPartners()")
  207:         return items
  208:     def addContextData(self,path):
  209:         """Hinzufügen zu einer Sammlung"""
  210:         try:
  211:             urllib.urlopen(self.REQUEST['SERVER_URL']+path+"/index.meta")
  212:             
  213:         except:
  214:             return "index.meta file has to exist!"
  215: 
  216:         links=[(path,'standard storage')]
  217:         
  218:         links+=OSAS_show.readContexts(path) # auslesen von contexten für den link
  219:         #print "LINK",links
  220:         self.REQUEST.SESSION['links']=links
  221:         pt=PageTemplateFile('Products/OSA_system/contextDataMain.zpt').__of__(self)
  222:         return pt()
  223:     
  224:     
  225:     def addContextData2(self,path,collection,context,science,practice,source_type,period,link,label,description,content_type,responsible,credits,weight):
  226:         """Hinzufuegen der Resource"""
  227:         splitted=path.split("/")
  228:         
  229:         id=splitted[len(splitted)-1]
  230:         title=splitted[len(splitted)-1]
  231:         metalink=self.REQUEST['SERVER_URL']+path+"/index.meta"
  232:         #link=TOBEDONE"
  233:         """Hinzufügen der Ressource"""
  234: 
  235:         
  236:         exec("collection_object=self"+collection)
  237:         
  238:         ECHO_collection.manage_AddECHO_resource(collection_object,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,weight,RESPONSE=None)
  239:         
  240:         getattr(collection_object,id).ECHO_getResourceMD()
  241:         #return "BLUByy"
  242:         return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path)
  243:         
  244:     manage_options = Folder.manage_options+(
  245:             {'label':'Main Config','action':'add_contextData_config'},
  246:             )
  247:         
  248:      
  249:     def add_contextData_config(self):
  250:         """Main configuration"""
  251:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_add_contextData.zpt').__of__(self)
  252:         return pt()
  253:     
  254:     
  255:     def change_OSAS_add_contextData(self,collection,RESPONSE=None):
  256:         """Change"""
  257:         self.collection=collection
  258:         if RESPONSE is not None:
  259:             RESPONSE.redirect('manage_main')
  260:             
  261: def manage_AddOSAS_add_contextDataForm(self):
  262:     """interface for adding the OSAS_add_Metadata"""
  263:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_contextData.zpt').__of__(self)
  264:     return pt()
  265: 
  266: def manage_AddOSAS_add_contextData(self,id,collection,RESPONSE=None):
  267:     """add the OSAS_root"""
  268:     newObj=OSAS_add_contextData(id,collection)
  269:     self.Destination()._setObject(id,newObj)
  270:     if RESPONSE is not None:
  271:         RESPONSE.redirect('manage_main')
  272: 
  273:             
  274: InitializeClass(OSAS_add_contextData)
  275: 
  276: class OSAS_add_Presentation(Folder):
  277:     """Hinzufügen der Presentationsinformationen"""
  278:     security=ClassSecurityInfo()
  279: 
  280:     def __init__(self,id):
  281:         """initialize a new instance"""
  282:         self.id = id
  283:         
  284:         
  285:     meta_type='OSAS_add_Presentation'    
  286:     manage_options = Folder.manage_options+(
  287:             {'label':'Main Config','action':'add_Presentation_config'},
  288:             )
  289:         
  290:      
  291:         
  292:     security.declarePublic('add_Presentation_config')
  293:     def add_Presentation_config(self):
  294:         """Main configuration"""
  295:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_addPresentation.zpt').__of__(self)
  296:         return pt()
  297:     
  298:     security.declarePublic('change_OSAS_add_Presentation')
  299:     def change_OSAS_add_Presentation(self,RESPONSE=None):
  300:         """Change"""
  301: #        self.RootFolderName=RootFolderName
  302:         if RESPONSE is not None:
  303:             RESPONSE.redirect('manage_main')
  304: 
  305:     def addPresentation(self,path):
  306:         """Hinzufügen der Presenationsinformation"""
  307:         return OSAS_add.addPresentation(self,path)
  308: 
  309:     def addPresentation2(self):
  310:         """Eingabe von Metadateninformationen"""
  311:         return OSAS_add.addPresentation2(self)
  312:     
  313: def manage_AddOSAS_add_PresentationForm(self):
  314:     """interface for adding the OSAS_add_Metadata"""
  315:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_presentation.zpt').__of__(self)
  316:     return pt()
  317: 
  318: def manage_AddOSAS_add_Presentation(self,id,RESPONSE=None):
  319:     """add the OSAS_root"""
  320:     newObj=OSAS_add_Presentation(id)
  321:     self.Destination()._setObject(id,newObj)
  322:     if RESPONSE is not None:
  323:         RESPONSE.redirect('manage_main')
  324: 
  325:             
  326: InitializeClass(OSAS_add_Presentation)
  327: 
  328: class OSAS_combineTextImage(Folder):
  329:     """Hinzufügen der Combine Text und Image"""
  330:     security=ClassSecurityInfo()
  331: 
  332:     def __init__(self,id):
  333:         """initialize a new instance"""
  334:         self.id = id
  335:         
  336:         
  337:     meta_type='OSAS_combineTextImage'    
  338:     manage_options = Folder.manage_options+(
  339:             {'label':'Main Config','action':'combineTextImage_config'},
  340:             )
  341:         
  342:      
  343:         
  344:     security.declarePublic('combineTextImage_config')
  345:     def combineTextImage_config(self):
  346:         """Main configuration"""
  347:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_combineTextImage.zpt').__of__(self)
  348:         return pt()
  349:     
  350:     security.declarePublic('change_OSAS_combineTextImage')
  351:     def change_OSAS_combineTextImage(self,RESPONSE=None):
  352:         """Change"""
  353: #        self.RootFolderName=RootFolderName
  354:         if RESPONSE is not None:
  355:             RESPONSE.redirect('manage_main')
  356:             
  357:     security.declarePublic('combineTextImage')
  358:     def combineTextImage(self,path):
  359:         """Hinzufügen der Presenationsinformation"""
  360:         return OSAS_add.combineTextImage(self,path)
  361: 
  362:     def combineTextImage2(self,path):
  363:         """Eingabe von Metadateninformationen"""
  364:         OSAS_add.combineTextImage2(self,path) # Add images
  365:         splitted=path.split("/")
  366:         linkPath=splitted[len(splitted)-1]
  367:         linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de:86/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath
  368:         self.REQUEST.SESSION['linkViewerEnvironment']=linkViewerEnvironment
  369: 
  370:         writeToContext(path,linkViewerEnvironment,"ECHO standard environment")
  371:         
  372:         pt=PageTemplateFile('Products/OSA_system/AddOSAS_combineTextImageFinal.zpt').__of__(self)
  373: 
  374:         return pt()
  375: 
  376: 
  377: def writeToContext(path,link,description):
  378:     """Created an additional entry to the index.meta file of path"""
  379:     dom=xml.dom.minidom.parse(path+"/index.meta")
  380:     node=dom.getElementsByTagName('resource')[0]
  381: 
  382:     subnode=dom.createElement('context')
  383: 
  384:     linknode=dom.createElement('link')
  385:     namelinknode=dom.createTextNode(link)
  386:     linknode.appendChild(namelinknode)
  387:     subnode.appendChild(linknode)
  388: 
  389:     linknode=dom.createElement('name')
  390:     namelinknode=dom.createTextNode(description)
  391:     linknode.appendChild(namelinknode)
  392:     subnode.appendChild(linknode)
  393: 
  394:     node.appendChild(subnode)
  395:     
  396:     writefile=file(path+"/index.meta","w")
  397:     #print path+"/index.meta"
  398:     writefile.write(dom.toxml().encode('utf-8'))
  399:     writefile.close()
  400: 
  401: def manage_AddOSAS_combineTextImageForm(self):
  402:     """interface for adding the OSAS_add_Metadata"""
  403:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_combineTextImage.zpt').__of__(self)
  404:     return pt()
  405: 
  406: def manage_AddOSAS_combineTextImage(self,id,RESPONSE=None):
  407:     """add the OSAS_root"""
  408:     newObj=OSAS_combineTextImage(id)
  409:     self.Destination()._setObject(id,newObj)
  410:     if RESPONSE is not None:
  411:         RESPONSE.redirect('manage_main')
  412: 
  413:             
  414: InitializeClass(OSAS_combineTextImage)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>