File:  [Repository] / OSAS / OSA_system / OSAS_addfiles.py
Revision 1.9: download - view: text, annotated - select for diffs - revision graph
Thu Oct 9 09:57:50 2003 UTC (20 years, 8 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
added link für collection

    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)+"<br>"
  188:             else:
  189:                 tmp=tmp+spaces(2*depth)
  190:                 tmp = tmp+retLink(child[1])+"<br>"
  191: 
  192:         return tmp
  193:                     
  194:     def generateTree(self,depth=3):
  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,3)
  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:         links=OSAS_show.readContexts(path) # auslesen von contexten für den link
  218:         self.REQUEST.SESSION['links']=links
  219:         pt=PageTemplateFile('Products/OSA_system/contextDataMain.zpt').__of__(self)
  220:         return pt()
  221:     
  222:     
  223:     def addContextData2(self,path,collection,context,science,practice,source_type,period,link,label,description,content_type,responsible,credits):
  224:         """Hinzufuegen der Resource"""
  225:         splitted=path.split("/")
  226:         
  227:         id=splitted[len(splitted)-1]
  228:         title=splitted[len(splitted)-1]
  229:         metalink=self.REQUEST['SERVER_URL']+path+"/index.meta"
  230:         #link=TOBEDONE"
  231:         """Hinzufügen der Ressource"""
  232: 
  233:         
  234:         exec("collection_object=self"+collection)
  235:         
  236:         ECHO_collection.manage_AddECHO_resource(collection_object,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,RESPONSE=None)
  237: 
  238:         getattr(collection_object,id).ECHO_getResourceMD()
  239: 
  240:         return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path)
  241:         
  242:     manage_options = Folder.manage_options+(
  243:             {'label':'Main Config','action':'add_contextData_config'},
  244:             )
  245:         
  246:      
  247:     def add_contextData_config(self):
  248:         """Main configuration"""
  249:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_add_contextData.zpt').__of__(self)
  250:         return pt()
  251:     
  252:     
  253:     def change_OSAS_add_contextData(self,collection,RESPONSE=None):
  254:         """Change"""
  255:         self.collection=collection
  256:         if RESPONSE is not None:
  257:             RESPONSE.redirect('manage_main')
  258:             
  259: def manage_AddOSAS_add_contextDataForm(self):
  260:     """interface for adding the OSAS_add_Metadata"""
  261:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_contextData.zpt').__of__(self)
  262:     return pt()
  263: 
  264: def manage_AddOSAS_add_contextData(self,id,collection,RESPONSE=None):
  265:     """add the OSAS_root"""
  266:     newObj=OSAS_add_contextData(id,collection)
  267:     self.Destination()._setObject(id,newObj)
  268:     if RESPONSE is not None:
  269:         RESPONSE.redirect('manage_main')
  270: 
  271:             
  272: InitializeClass(OSAS_add_contextData)
  273: 
  274: class OSAS_add_Presentation(Folder):
  275:     """Hinzufügen der Presentationsinformationen"""
  276:     security=ClassSecurityInfo()
  277: 
  278:     def __init__(self,id):
  279:         """initialize a new instance"""
  280:         self.id = id
  281:         
  282:         
  283:     meta_type='OSAS_add_Presentation'    
  284:     manage_options = Folder.manage_options+(
  285:             {'label':'Main Config','action':'add_Presentation_config'},
  286:             )
  287:         
  288:      
  289:         
  290:     security.declarePublic('add_Presentation_config')
  291:     def add_Presentation_config(self):
  292:         """Main configuration"""
  293:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_addPresentation.zpt').__of__(self)
  294:         return pt()
  295:     
  296:     security.declarePublic('change_OSAS_add_Presentation')
  297:     def change_OSAS_add_Presentation(self,RESPONSE=None):
  298:         """Change"""
  299: #        self.RootFolderName=RootFolderName
  300:         if RESPONSE is not None:
  301:             RESPONSE.redirect('manage_main')
  302: 
  303:     def addPresentation(self,path):
  304:         """Hinzufügen der Presenationsinformation"""
  305:         return OSAS_add.addPresentation(self,path)
  306: 
  307:     def addPresentation2(self):
  308:         """Eingabe von Metadateninformationen"""
  309:         return OSAS_add.addPresentation2(self)
  310:     
  311: def manage_AddOSAS_add_PresentationForm(self):
  312:     """interface for adding the OSAS_add_Metadata"""
  313:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_presentation.zpt').__of__(self)
  314:     return pt()
  315: 
  316: def manage_AddOSAS_add_Presentation(self,id,RESPONSE=None):
  317:     """add the OSAS_root"""
  318:     newObj=OSAS_add_Presentation(id)
  319:     self.Destination()._setObject(id,newObj)
  320:     if RESPONSE is not None:
  321:         RESPONSE.redirect('manage_main')
  322: 
  323:             
  324: InitializeClass(OSAS_add_Presentation)
  325: 
  326: class OSAS_combineTextImage(Folder):
  327:     """Hinzufügen der Combine Text und Image"""
  328:     security=ClassSecurityInfo()
  329: 
  330:     def __init__(self,id):
  331:         """initialize a new instance"""
  332:         self.id = id
  333:         
  334:         
  335:     meta_type='OSAS_combineTextImage'    
  336:     manage_options = Folder.manage_options+(
  337:             {'label':'Main Config','action':'combineTextImage_config'},
  338:             )
  339:         
  340:      
  341:         
  342:     security.declarePublic('combineTextImage_config')
  343:     def combineTextImage_config(self):
  344:         """Main configuration"""
  345:         pt=PageTemplateFile('Products/OSA_system/ChangeOSAS_combineTextImage.zpt').__of__(self)
  346:         return pt()
  347:     
  348:     security.declarePublic('change_OSAS_combineTextImage')
  349:     def change_OSAS_combineTextImage(self,RESPONSE=None):
  350:         """Change"""
  351: #        self.RootFolderName=RootFolderName
  352:         if RESPONSE is not None:
  353:             RESPONSE.redirect('manage_main')
  354:             
  355:     security.declarePublic('combineTextImage')
  356:     def combineTextImage(self,path):
  357:         """Hinzufügen der Presenationsinformation"""
  358:         return OSAS_add.combineTextImage(self,path)
  359: 
  360:     def combineTextImage2(self,path):
  361:         """Eingabe von Metadateninformationen"""
  362:         OSAS_add.combineTextImage2(self,path) # Add images
  363:         splitted=path.split("/")
  364:         linkPath=splitted[len(splitted)-1]
  365:         linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de:86/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath
  366:         self.REQUEST.SESSION['linkViewerEnvironment']=linkViewerEnvironment
  367: 
  368:         writeToContext(path,linkViewerEnvironment,"ECHO standard environment")
  369:         
  370:         pt=PageTemplateFile('Products/OSA_system/AddOSAS_combineTextImageFinal.zpt').__of__(self)
  371: 
  372:         return pt()
  373: 
  374: 
  375: def writeToContext(path,link,description):
  376:     """Created an additional entry to the index.meta file of path"""
  377:     dom=xml.dom.minidom.parse(path+"/index.meta")
  378:     node=dom.getElementsByTagName('resource')[0]
  379: 
  380:     subnode=dom.createElement('context')
  381: 
  382:     linknode=dom.createElement('link')
  383:     namelinknode=dom.createTextNode(link)
  384:     linknode.appendChild(namelinknode)
  385:     subnode.appendChild(linknode)
  386: 
  387:     linknode=dom.createElement('name')
  388:     namelinknode=dom.createTextNode(description)
  389:     linknode.appendChild(namelinknode)
  390:     subnode.appendChild(linknode)
  391: 
  392:     node.appendChild(subnode)
  393:     
  394:     writefile=file(path+"/index.meta","w")
  395:     #print path+"/index.meta"
  396:     writefile.write(dom.toxml().encode('utf-8'))
  397:     writefile.close()
  398: 
  399: def manage_AddOSAS_combineTextImageForm(self):
  400:     """interface for adding the OSAS_add_Metadata"""
  401:     pt=PageTemplateFile('Products/OSA_system/AddOSAS_combineTextImage.zpt').__of__(self)
  402:     return pt()
  403: 
  404: def manage_AddOSAS_combineTextImage(self,id,RESPONSE=None):
  405:     """add the OSAS_root"""
  406:     newObj=OSAS_combineTextImage(id)
  407:     self.Destination()._setObject(id,newObj)
  408:     if RESPONSE is not None:
  409:         RESPONSE.redirect('manage_main')
  410: 
  411:             
  412: InitializeClass(OSAS_combineTextImage)

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