Annotation of OSAS/OSA_system/OSAS_addfiles.py, revision 1.6

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

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