[Zapp-cvs-commit] ZApp/skins/zapp_generic zapp_cook_id.py,NONE,1.1 zapp_get_filesFolderObject.py,NON
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2004-01-16 09:55:44
|
Update of /cvsroot/zapp/ZApp/skins/zapp_generic
In directory sc8-pr-cvs1:/tmp/cvs-serv22109/skins/zapp_generic
Modified Files:
zapp_file_edit.py zapp_file_edit_form.pt zapp_file_view.pt
zapp_get_fileObj.py zapp_image_edit.py zapp_image_edit_form.pt
zapp_image_view.pt
Added Files:
zapp_cook_id.py zapp_get_filesFolderObject.py zapp_show_swf.pt
Log Message:
file system based image handling for Plone
--- NEW FILE: zapp_cook_id.py ---
## Script (Python) "hec_image_edit"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=id, title, file
##title=
##
if not id and hasattr(file,'filename'):
filename=file.filename
title=title or filename
id=filename[max(filename.rfind('/'),
filename.rfind('\\'),
filename.rfind(':'),
)+1:]
return id, title
--- NEW FILE: zapp_get_filesFolderObject.py ---
## Script (Python) "zapp_get_fileObj"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=debug=0
##title=
##
try:
path = context.getPhysicalPath()
fileID = path[-1]
currFolder = context.fSystem
for folder in path[1:-1]:
if folder in currFolder.objectIds('Folder'):
fsFolder = getattr(currFolder, folder, None)
if not fsFolder:
raise RuntimeError, "Can't find folder!" + folder
currFolder = fsFolder
except:
return 'ack!'
if not debug:
return currFolder
return currFolder.getId()
--- NEW FILE: zapp_show_swf.pt ---
<div metal:define-macro="main">
<tal:block tal:omit-tag="" define="main_name python:'.'.join(path('here/getId').split('.')[:-1]);
swf_url here/graphic_url">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
tal:attributes="id main_name" ALIGN="">
<PARAM NAME=movie tal:attributes="VALUE swf_url">
<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED tal:attributes="src swf_url;NAME main_name" quality=high bgcolor=#FFFFFF
ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</tal:block>
</div>
Index: zapp_file_edit.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_file_edit.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_file_edit.py 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_file_edit.py 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 10,26 ****
# Example code:
! file = context.REQUEST.form.get('file','')
!
! portal = context.portal_url.getPortalObject()
!
if not file:
! return "I need a file!"
! path = context.getPhysicalPath()
! print "I got a ", `file`
fileID = path[-1]
currFolder = portal.fSystem
--- 10,28 ----
# Example code:
! REQUEST = context.REQUEST
! file = REQUEST.form.get('file','')
if not file:
! raise RuntimeError, "I need a file!"
! print file.filename
! return printed
! oldID = context.getId()
! portal = context.portal_url.getPortalObject()
! path = context.getPhysicalPath()
fileID = path[-1]
+ newID = REQUEST.form.get('id',oldID)
currFolder = portal.fSystem
***************
*** 36,56 ****
currFolder = fsFolder
-
fileObj = getattr(currFolder, fileID, None)
- #print "adding ", `fileObj`," with id ", fileObj.id, " image to ", `currFolder`, currFolder.id
-
if fileObj is None:
currFolder.manage_addFile(id=fileID, file=file)
fileObj = getattr(currFolder, fileID, None)
- print "I'm creating a file object.. "
! try:
! print "I'm trying to upload a file"
! fileObj.manage_upload(file)
! except:
! print "I failed.. by getting a ", `fileObj`
! return printed
context.REQUEST.RESPONSE.redirect('view')
--- 38,50 ----
currFolder = fsFolder
fileObj = getattr(currFolder, fileID, None)
if fileObj is None:
currFolder.manage_addFile(id=fileID, file=file)
fileObj = getattr(currFolder, fileID, None)
! print "I'm trying to upload a file"
! fileObj.manage_upload(file)
context.REQUEST.RESPONSE.redirect('view')
Index: zapp_file_edit_form.pt
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_file_edit_form.pt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_file_edit_form.pt 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_file_edit_form.pt 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 12,33 ****
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
! <form action="hec_file_edit" method="post" enctype="multipart/form-data"
! tal:attributes="action string:${here/absolute_url}/hec_file_edit"
>
<table class="FormLayout">
<tr>
! <th i18n:translate="">Title</th>
! <td> <span tal:replace="here/Title">My Title</span></td>
! </tr>
!
! <tr>
! <th i18n:translate="">Description</th>
! <td> <span tal:replace="here/Description">My Description</span></td>
</tr>
<tr>
! <th i18n:translate="">Content type</th>
! <td> <span tal:replace="here/Format">html/text</span></td>
</tr>
--- 12,28 ----
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
! <form action="zapp_file_edit" method="post" enctype="multipart/form-data"
! tal:attributes="action string:${here/absolute_url}/zapp_file_edit"
>
<table class="FormLayout">
<tr>
! <th i18n:translate="">Short Name (id: no spaces!)</th>
! <td> <input name="id" tal:attributes="value here/id" value=""/></td>
</tr>
<tr>
! <th i18n:translate="">Title</th>
! <td> <input name="title" tal:attributes="value here/Title" value=""/></td>
</tr>
Index: zapp_file_view.pt
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_file_view.pt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_file_view.pt 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_file_view.pt 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 18,23 ****
</div>
- <div metal:use-macro="here/content_byline/macros/byline">By Me</div>
-
</div>
--- 18,21 ----
***************
*** 26,30 ****
<h2 i18n:translate=""> File Properties </h2>
! <table tal:define="theFile here/hec_image_get_fileObj">
<tr>
--- 24,28 ----
<h2 i18n:translate=""> File Properties </h2>
! <table tal:define="theFile here/zapp_get_fileObj">
<tr>
Index: zapp_get_fileObj.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_get_fileObj.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_get_fileObj.py 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_get_fileObj.py 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 1,16 ****
! portal = context.portal_url.getPortalObject()
! path = context.getPhysicalPath()
! fileID = path[-1]
! currFolder = portal.fSystem
!
! for folder in path[1:-1]:
! if folder in currFolder.objectIds('Folder'):
! fsFolder = getattr(currFolder, folder, None)
!
! if not fsFolder:
! raise RuntimeError, "Can't find folder!" + folder
!
! currFolder = fsFolder
!
! return getattr(currFolder, fileID, None)
--- 1,12 ----
! ## Script (Python) "zapp_get_fileObj"
! ##bind container=container
! ##bind context=context
! ##bind namespace=
! ##bind script=script
! ##bind subpath=traverse_subpath
! ##parameters=
! ##title=
! ##
! currFolder = context.zapp_get_filesFolderObject()
! return getattr(currFolder, context.getId(), 'Ack!')
Index: zapp_image_edit.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_image_edit.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_image_edit.py 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_image_edit.py 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 10,26 ****
# Example code:
! file = context.REQUEST.form.get('file','')
!
! portal = context.portal_url.getPortalObject()
!
if not file:
! return "I need a file!"
path = context.getPhysicalPath()
! print "I got a ", `file`
!
! fileID = path[-1]
!
currFolder = portal.fSystem
--- 10,23 ----
# Example code:
! REQUEST = context.REQUEST
! file = REQUEST.form.get('file','')
if not file:
! raise RuntimeError, "I need a file!"
+ portal = context.portal_url.getPortalObject()
path = context.getPhysicalPath()
! oldID = path[-1]
! newID, newTitle = context.zapp_cook_id( REQUEST.get('id',''), REQUEST.get('title',''), file)
currFolder = portal.fSystem
***************
*** 37,56 ****
currFolder = fsFolder
! fileObj = getattr(currFolder, fileID, None)
! #print "adding ", `fileObj`," with id ", fileObj.id, " image to ", `currFolder`, currFolder.id
- if fileObj is None:
- currFolder.manage_addImage(id=fileID, file=file)
- fileObj = getattr(currFolder, fileID, None)
- print "I'm creating a file object.. "
- try:
- print "I'm trying to upload a file"
- fileObj.manage_upload(file)
- except:
- print "I failed.. by getting a ", `fileObj`
- return printed
-
- context.REQUEST.RESPONSE.redirect('view')
--- 34,51 ----
currFolder = fsFolder
+ fileObj = getattr(currFolder, oldID, None)
! if fileObj is None:
! currFolder.manage_addImage(id=newID, file=file)
! fileObj = getattr(currFolder, newID, None)
! else:
! if newID != oldID:
! currFolder.manage_renameObjects((oldID,), (newID,))
!
! fileObj = getattr(currFolder, newID, None)
! fileObj.manage_upload(file)
!
! REQUEST.RESPONSE.redirect( "%s/folder_rename?ids:list=%s&new_ids:list=%s&new_titles:list=%s" % (REQUEST.get('URL2'), oldID, newID, newTitle))
Index: zapp_image_edit_form.pt
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_image_edit_form.pt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_image_edit_form.pt 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_image_edit_form.pt 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 14,35 ****
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
! <form action="hec_image_edit" method="post" enctype="multipart/form-data"
! tal:attributes="action string:${here/absolute_url}/hec_image_edit"
>
<table class="FormLayout">
<tr>
! <th i18n:translate="">Title</th>
! <td> <span tal:replace="here/Title">My Title</span> </td>
! </tr>
!
! <tr>
! <th i18n:translate="">Description</th>
! <td> <span tal:replace="here/Description">My Description</span> </td>
</tr>
<tr>
! <th i18n:translate="">Content type</th>
! <td> <span tal:replace="here/Format">text/html</span> </td>
</tr>
--- 14,30 ----
tal:replace="here/getId" i18n:name="objectid">My ID</span></h2>
! <form action="zapp_image_edit" method="post" enctype="multipart/form-data"
! tal:attributes="action string:${here/absolute_url}/zapp_image_edit"
>
<table class="FormLayout">
<tr>
! <th i18n:translate="">Short Name (id: no spaces!)</th>
! <td> <input name="id" tal:attributes="value here/id" value=""/></td>
</tr>
<tr>
! <th i18n:translate="">Title</th>
! <td> <input name="title" tal:attributes="value here/Title" value=""/></td>
</tr>
Index: zapp_image_view.pt
===================================================================
RCS file: /cvsroot/zapp/ZApp/skins/zapp_generic/zapp_image_view.pt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** zapp_image_view.pt 25 Jun 2003 11:45:53 -0000 1.1
--- zapp_image_view.pt 16 Jan 2004 09:55:34 -0000 1.2
***************
*** 9,35 ****
<div metal:fill-slot="header">
-
<h1 id="DesktopTitle"
tal:content="here/Title">Document Title</h1>
-
<div id="DesktopDescription" tal:content="here/Description">
Document Description goes here.
</div>
-
- <div metal:use-macro="here/content_byline/macros/byline">By Me</div>
-
</div>
<div metal:fill-slot="main">
! <img tal:attributes="src python:here.hec_image_get_fileObj().absolute_url()"/>
!
! <div class="Discussion">
! <span tal:replace="structure here/viewThreadsAtBottom"
! tal:condition="here/viewThreadsAtBottom|nothing"></span>
</div>
</div>
</body>
! </html>
--- 9,32 ----
<div metal:fill-slot="header">
<h1 id="DesktopTitle"
tal:content="here/Title">Document Title</h1>
<div id="DesktopDescription" tal:content="here/Description">
Document Description goes here.
</div>
</div>
<div metal:fill-slot="main">
! <div tal:condition="python:here.Format() == 'application/x-shockwave-flash'">
! <div metal:use-macro="here/zapp_show_swf/macros/main">
! Sorry!
! </div>
</div>
+ <div tal:condition="python:here.Format() != 'application/x-shockwave-flash'">
+ <img tal:attributes="src python:here.zapp_get_fileObj().absolute_url()"/>
+ </div>
</div>
</body>
! </html>
\ No newline at end of file
|