--- lise/lise.py 2004/04/14 16:43:30 1.2 +++ lise/lise.py 2004/04/23 16:25:09 1.3 @@ -14,9 +14,11 @@ from Products.PageTemplates.ZopePageTemp import os from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplate import PageTemplate +from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate import string import urllib import xml.dom.minidom +from urllib import quote ### G L O B A L S ### @@ -91,6 +93,31 @@ class lise(Folder): manage_addliseForm = DTMLFile('dtml/manage_addliseForm', globals()) +class MAIN_layoutTemplate(ZopePageTemplate): + """Create a layout Template""" + + meta_type="MAIN_layoutTemplate" + + def __init__(self, id, text=None, content_type=None, MainType=None): + self.id = str(id) + + self.ZBindings_edit(self._default_bindings) + if text is None: + self._default_content_fn = os.path.join(package_home(globals()), + 'dtml/main.zpt') + text = open(self._default_content_fn).read() + self.pt_edit(text, content_type) + + + """change form""" + + +def manage_addNAIN_layoutTemplateForm(self): + """Form for adding""" + pt = PageTemplateFile('Products/lise/dtml/main.zpt').__of__(self) + return pt() + + def manage_addlise(self, id, title, pictpath, baseurl, file, RESPONSE = None): "add a lise instance in a folder." global allobjects @@ -124,8 +151,7 @@ def manage_addlise(self, id, title, pict fnames = [] id = str(id) title = str(title) - if IsStr(gbaseurl): - gbaseurl = str(baseurl) + gpictpath = str(pictpath) thelen = len(gpictpath) @@ -136,7 +162,13 @@ def manage_addlise(self, id, title, pict for i in fnames: if i[0] <> '.': normalize_whitespace(i) - filenames.append('file://' + gpictpath + '/' + i) +# filenames.append('file://' + gpictpath + '/' + i) + if gpictpath[-1] == '/': + filenames.append('file://' + gpictpath + i) + else: + filenames.append('file://' + gpictpath + '/' + i) + else: + filenames.append('no_fuckingPicture') newObj = lise(id, title) # create new lise object self._setObject(id, newObj) # put it into zope @@ -170,18 +202,25 @@ def manage_addlise(self, id, title, pict p.CharacterDataHandler = taghandler.characters p.Parse(str(object2.data)) + if IsStr(baseurl): + gbaseurl = str(baseurl) + + #### lšschen nicht vergessen ### +# gbaseurl = 'http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=permanent/shipbuilding/bougu_traite_1746&dw=400&dh=400&pn=' + for i in allobjects: if hasattr(i, 'typestr'): if i.typestr == 'chapter': i.parseobjects() - + counterid = 1 for i in allobjects: if hasattr(i, 'typestr'): if i.typestr == 'chapter': i.CreateChapter() if i.typestr == 'page': - i.CreatePage() + i.CreatePage(i.chapterindex) + pacount = 0 for i in pagearray: @@ -195,7 +234,6 @@ def manage_addlise(self, id, title, pict break if IsInt(pagearray[j].pictindex): i.pictindex = pagearray[j].pictindex - i.picturelink = '' break pacount = pacount + 1 @@ -500,7 +538,7 @@ def IsStr(str): class PageObject: def __init__(self): self.name = "" - self.index = "" + self.index = 0 self.pictindex = 0 self.url = "" self.isselected = False @@ -510,7 +548,7 @@ class PageObject: self.nextref = 0 self.chapref = 0 - def CreatePage(self): + def CreatePage(self, level): global counter global counterid global gbaseurl @@ -518,18 +556,36 @@ class PageObject: global pagearray global errstr + self.chapterindex = level pageelement = PageElement() pageelement.id = str(counterid) pageelement.type = "P" pageelement.name = self.name if IsStr(self.url): if len(self.url) > 0: - pageelement.picturelink = gbaseurl + '/' + self.url + if IsStr(gbaseurl): + if len(gbaseurl) > 0: + if gbaseurl[-1] == '/': + pageelement.picturelink = gbaseurl + self.url + else: + pageelement.picturelink = gbaseurl + '/' + self.url + else: + pageelement.picturelink = self.url + else: + if IsStr(gbaseurl): + pageelement.picturelink = gbaseurl + else: + pageelement.picturelink = gbaseurl pageelement.level = self.chapterindex + if IsInt(self.index): - if int(self.index) > 0: - pageelement.pictindex = int(self.index) - 1 + if int(self.index) >= 0: + pageelement.pictindex = int(self.index) + if IsStr(pageelement.picturelink): + if len(pageelement.picturelink) > 0: + pageelement.picturelink = pageelement.picturelink + str(self.index + 1) + else: pageelement.pictindex = '9999' else: @@ -601,7 +657,7 @@ class ChapterObject: def CreateChapter(self): global counter global counterid - global baseurl + global gbaseurl global pagearray global errstr @@ -622,7 +678,7 @@ class ChapterObject: count += 1 if hasattr(self, 'typestr'): if i.typestr == 'page': - i.CreatePage() + i.CreatePage(self.chapterindex + 1) if i.typestr == 'chapter': i.CreateChapter() if i.typestr == 'start': @@ -655,10 +711,12 @@ class ChapterObject: pageelement.type = "P" pageelement.open = 0 pageelement.pictindex = j + pageelement.picturelink = gbaseurl + str(j) pagearray.append(pageelement) currlen = len(pagearray) if pagearray[currlen - 2].type == 'C': pagearray[currlen - 2].pictindex = j + pagearray[currlen - 2].picturelink = gbaseurl + str(j) counter = counter + 1 counterid = counterid + 1 currcount = currcount + 1 @@ -693,6 +751,7 @@ class ChapterObject: pageelement.type = "P" pageelement.open = 0 pageelement.pictindex = j + pageelement.picturelink = gbaseurl + str(j) pagearray.append(pageelement) counter = counter + 1