Back to index

plone3  3.1.7
Functions | Variables
kupuUploadImage Namespace Reference

Functions

def Error
def cleanupFilename

Variables

 request = context.REQUEST
 RESPONSE = request.RESPONSE
string TEMPLATE
tuple kupu_tool = getToolByName(context, 'kupu_library_tool')
tuple ctr_tool = getToolByName(context, 'content_type_registry')
list id = request['node_prop_image']
tuple linkbyuid = kupu_tool.getLinkbyuid()
tuple base = context.absolute_url()
list content_type = request['node_prop_image']
tuple typename = ctr_tool.findTypeName(id, content_type, "")
tuple newid
tuple obj = getattr(context,newid, None)
string url = '/resolveuid/%s'

Function Documentation

Generate a unique id which doesn't match
the system generated ids.
The reason being that setImage will blow up if we have a system
generated id and the id it generates from the filename is already in use.

Definition at line 27 of file kupuUploadImage.py.

00027 
00028 def cleanupFilename(name):
00029     """Generate a unique id which doesn't match
00030     the system generated ids.
00031     The reason being that setImage will blow up if we have a system
00032     generated id and the id it generates from the filename is already in use.
00033     """
00034     id = ''
00035     name = name.replace('\\', '/') # Fixup Windows filenames
00036     name = name.split('/')[-1] # Throw away any path part.
00037     for c in name:
00038         if c.isalnum() or c in '._':
00039             id += c
00040 
00041     # Race condition here, but not a lot we can do about that
00042     if context.check_id(id) is None and getattr(context,id,None) is None:
00043         return id
00044 
00045     # Now make the id unique
00046     parts = id.split('.')
00047     if len(parts)==1: parts.append('')
00048     count = 1
00049     while 1:
00050         if count==1:
00051             sc = ''
00052         else:
00053             sc = str(count)
00054         id = "copy%s_of_%s" % (sc, id)
00055         if context.check_id(id) is None and getattr(context,id,None) is None:
00056             return id
00057         count += 1

def kupuUploadImage.Error (   fmt,
  args 
)

Definition at line 22 of file kupuUploadImage.py.

00022 
00023 def Error(fmt, *args):
00024     msg = fmt % args
00025     script = TEMPLATE % ('cancelUpload', msg.replace("'", "\\'"), newline_to_br(html_quote(printed)))
00026     return script


Variable Documentation

tuple kupuUploadImage.base = context.absolute_url()

Definition at line 63 of file kupuUploadImage.py.

list kupuUploadImage.content_type = request['node_prop_image']

Definition at line 68 of file kupuUploadImage.py.

tuple kupuUploadImage.ctr_tool = getToolByName(context, 'content_type_registry')

Definition at line 59 of file kupuUploadImage.py.

tuple kupuUploadImage.id = request['node_prop_image']

Definition at line 61 of file kupuUploadImage.py.

tuple kupuUploadImage.kupu_tool = getToolByName(context, 'kupu_library_tool')

Definition at line 58 of file kupuUploadImage.py.

tuple kupuUploadImage.linkbyuid = kupu_tool.getLinkbyuid()

Definition at line 62 of file kupuUploadImage.py.

Initial value:
00001 context.invokeFactory(type_name=typename, id=id,
00002     title=node_prop_title,
00003     description=node_prop_desc,
00004     )

Definition at line 84 of file kupuUploadImage.py.

tuple kupuUploadImage.obj = getattr(context,newid, None)

Definition at line 92 of file kupuUploadImage.py.

kupuUploadImage.request = context.REQUEST

Definition at line 11 of file kupuUploadImage.py.

kupuUploadImage.RESPONSE = request.RESPONSE

Definition at line 12 of file kupuUploadImage.py.

Initial value:
00001 """
00002 <html>
00003 <head></head>
00004 <body onload="window.parent.drawertool.current_drawer.%s('%s');">%s
00005 </body>
00006 </html>
00007 """

Definition at line 14 of file kupuUploadImage.py.

tuple kupuUploadImage.typename = ctr_tool.findTypeName(id, content_type, "")

Definition at line 69 of file kupuUploadImage.py.

tuple kupuUploadImage.url = '/resolveuid/%s'

Definition at line 100 of file kupuUploadImage.py.