[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue forms/src/GFClient.py common/src/__init__.py
From: |
Jan Ischebeck |
Subject: |
gnue forms/src/GFClient.py common/src/__init__.py |
Date: |
Sun, 15 Sep 2002 16:54:57 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/09/15 16:54:57
Modified files:
forms/src : GFClient.py
common/src : __init__.py
Log message:
* make gnue-forms use openResource (gnue-common) instead of openurl
* allow openResource to transparently access files stored in a zip
archive
(this special zip archive is called gear for now)
* allow navigator to open these zip files and get an process definition
file which describes the archive content created on the fly
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFClient.py.diff?tr1=1.47&tr2=1.48&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/__init__.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gnue/common/src/__init__.py
diff -c gnue/common/src/__init__.py:1.14 gnue/common/src/__init__.py:1.15
*** gnue/common/src/__init__.py:1.14 Wed Sep 11 16:23:42 2002
--- gnue/common/src/__init__.py Sun Sep 15 16:54:57 2002
***************
*** 55,64 ****
__version__ = VERSION
__hexversion__ = HEXVERSION
! import os
! import urllib
import string
#
# Open a file or URL resource,
# properly handling drive letters.
--- 55,102 ----
__version__ = VERSION
__hexversion__ = HEXVERSION
! import os,sys
! import urllib,urlparse,cStringIO,zipfile
import string
+ def buildNavigationfile(list,name,top=0):
+ if top:
+ navi='<?xml version="1.0"?>\n\n'+\
+ '<processes title="Package '+name+'">\n'
+ else:
+ navi='<process title="'+name+'" id="'+name+'">\n'
+
+ for i in list.keys():
+ if type(list[i])==type(""):
+ if i[-4:]==".grd":
+ navi=navi+'<step type="report" location="'+list[i]+\
+ '" title="'+i+'">\n<description><![CDATA['+\
+ '<CENTER><H3>'+i+'</H3></CENTER>'+\
+ ']]></description>\n</step>\n'
+ elif i[-4:]==".gfd":
+ navi=navi+'<step type="form" location="'+list[i]+\
+ '" title="'+i+'">\n<description><![CDATA['+\
+ '<CENTER><H3>'+i+'</H3></CENTER>'+\
+ ']]></description>\n</step>\n'
+ elif i[-4:]==".gnd":
+ navi=navi+'<step type="navigator" location="'+list[i]+\
+ '" title="'+i+'">\n<description><![CDATA['+\
+ '<CENTER><H3>'+i+'</H3></CENTER>'+\
+ ']]></description>\n</step>\n'
+ elif i=="README":
+ navi=navi+'<description><![CDATA[<H3 ALIGN="CENTER">README</H3>'+\
+ list[i]+']]></description>\n'
+ else:
+ navi=navi+buildNavigationfile(list[i],i)
+
+ if top:
+ navi=navi+'</processes>\n'
+ else:
+ navi=navi+'</process>\n'
+ return navi
+
+
+
#
# Open a file or URL resource,
# properly handling drive letters.
***************
*** 68,74 ****
if len(drive[0]):
return open(resource,'r')
else:
! return urllib.urlopen(resource)
#
--- 106,187 ----
if len(drive[0]):
return open(resource,'r')
else:
! (urltype, host, path, param, query, frag) = urlparse.urlparse(resource)
!
! if resource[-5:]==".gear":
! host=resource
! path=""
! urltype="gear"
!
! if urltype!="gear":
! return urllib.urlopen(resource)
!
! # load gear://archive/path/xxx.gfd
! # TODO: * add Zipfile write support. i.e. write stringbuffer into zipfile
! # if .. close is called
! # * provide zipfile cache, i.e. load zipfile just once into memory
!
! else:
! # urlparse sometimes didn't work correctly
! if host=="":
! # path="//host/path" -> path=path host=host
! pathlist=string.split(path[2:],"/",1)
! host=pathlist[0]
! path=pathlist[1]
!
! # check if host ends in ".gear"
! if host[-5:]!=".gear":
! host=host+".gear"
!
! # 1. search for gear in the local directory
! try:
! zf=zipfile.ZipFile(host, mode="r")
! except:
! # 2. search in the package directory
! if sys.platform=="win32":
! host=sys.prefix+"/packages/"+host
! else:
! host=os.environ["HOME"]+"/gnue/packages/"+host
!
! zf=zipfile.ZipFile(host, mode="r")
!
! if len(path):
! return cStringIO.StringIO(zf.read(path))
!
! # if no path provided, create a navigator file for this archive
! else:
! list=zf.namelist()
!
! # check if the zip file contains a default navigator file
! if "default.gpd" in list:
! return cStringIO.StringIO(zf.read("default.gpd"))
!
! # convert a single filename to a full gear url
! if resource[:5]!="gear:":
! resource="gear://"+resource+"/"
!
! # reorder pathlist
! newlist={}
! for i in list:
! ps=string.split(i,"/",1)
! if ps[0]=="":
! ps[0]==ps[1]
! ps[1]=""
! if len(ps)==1 or ps[1]=="":
! newlist[ps[0]]=resource+i
! else:
! if not newlist.has_key(ps[0]):
! newlist[ps[0]]={}
!
! newlist[ps[0]][ps[1]]=resource+i
!
! if ps[1]=="README":
! buf=zf.read(i)
! buf=string.join(string.split(buf,"\n"),"<BR>\n")
! newlist[ps[0]][ps[1]]=buf
!
! navi=buildNavigationfile(newlist,host,1)
! return cStringIO.StringIO(navi)
#
Index: gnue/forms/src/GFClient.py
diff -c gnue/forms/src/GFClient.py:1.47 gnue/forms/src/GFClient.py:1.48
*** gnue/forms/src/GFClient.py:1.47 Tue Sep 10 11:30:50 2002
--- gnue/forms/src/GFClient.py Sun Sep 15 16:54:57 2002
***************
*** 176,186 ****
#
# Build the form tree
#
! drive = os.path.splitdrive(formFile)
! if len(drive[0]):
! fileHandle = open(formFile,'r')
! else:
! fileHandle = urllib.urlopen(formFile)
form = loadForm (fileHandle, instance)
fileHandle.close()
--- 176,182 ----
#
# Build the form tree
#
! fileHandle=openResource(formFile)
form = loadForm (fileHandle, instance)
fileHandle.close()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue forms/src/GFClient.py common/src/__init__.py,
Jan Ischebeck <=