File:  [Repository] / OSAS / OSA_system / OSAS_addfiles.py
Revision 1.17: download - view: text, annotated - select for diffs - revision graph
Wed Mar 3 13:02:54 2004 UTC (20 years, 3 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
moved templates to zpt

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

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