File:  [Repository] / OSAS / OSA_system / OSAS_addfiles.py
Revision 1.14: download - view: text, annotated - select for diffs - revision graph
Wed Jan 21 07:43:01 2004 UTC (20 years, 5 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
small changes

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

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