Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.action.twikidraw.TwikiDraw Class Reference
Collaboration diagram for MoinMoin.action.twikidraw.TwikiDraw:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def save
def render

Public Attributes

 request
 pagename
 target

Static Public Attributes

tuple basename = wikiutil.escape(target, 1)
tuple drawurl = wikiutil.escape(drawurl, 1)
tuple pngurl = wikiutil.escape(pngurl, 1)
tuple pageurl = wikiutil.escape(pageurl, 1)
tuple saveurl = wikiutil.escape(saveurl, 1)
tuple helpurl = wikiutil.escape(helpurl, 1)
string title = "%s %s:%s"

Detailed Description

twikidraw action 

Definition at line 102 of file twikidraw.py.


Constructor & Destructor Documentation

def MoinMoin.action.twikidraw.TwikiDraw.__init__ (   self,
  request,
  pagename,
  target 
)

Definition at line 104 of file twikidraw.py.

00104 
00105     def __init__(self, request, pagename, target):
00106         self.request = request
00107         self.pagename = pagename
00108         self.target = target


Member Function Documentation

Definition at line 151 of file twikidraw.py.

00151 
00152     def render(self):
00153         request = self.request
00154         _ = request.getText
00155         pagename = self.pagename
00156         target = self.target
00157         if not request.user.may.read(pagename):
00158             return _('You are not allowed to view attachments of this page.')
00159         if not target:
00160             return _("Empty target name given.")
00161 
00162         ci = AttachFile.ContainerItem(request, pagename, target)
00163         if ci.exists():
00164             drawurl = ci.member_url('drawing.draw')
00165             pngurl = ci.member_url('drawing.png')
00166         else:
00167             drawurl = 'drawing.draw'
00168             pngurl = 'drawing.png'
00169         pageurl = request.href(pagename)
00170         saveurl = request.href(pagename, action=action_name, do='save', target=target)
00171         helpurl = request.href("HelpOnActions/AttachFile")
00172 
00173         html = """
00174 <p>
00175 <applet code="CH.ifa.draw.twiki.TWikiDraw.class"
00176         archive="%(htdocs)s/applets/TWikiDrawPlugin/twikidraw.jar" width="640" height="480">
00177     <param name="drawpath" value="%(drawurl)s">
00178     <param name="pngpath"  value="%(pngurl)s">
00179     <param name="savepath" value="%(saveurl)s">
00180     <param name="basename" value="%(basename)s">
00181     <param name="viewpath" value="%(pageurl)s">
00182     <param name="helppath" value="%(helpurl)s">
00183     <strong>NOTE:</strong> You need a Java enabled browser to edit the drawing.
00184 </applet>
00185 </p>
""" % dict(

Definition at line 109 of file twikidraw.py.

00109 
00110     def save(self):
00111         request = self.request
00112         _ = request.getText
00113         pagename = self.pagename
00114         target = self.target
00115         if not request.user.may.write(pagename):
00116             return _('You are not allowed to save a drawing on this page.')
00117         if not target:
00118             return _("Empty target name given.")
00119 
00120         file_upload = request.files.get('filepath')
00121         if not file_upload:
00122             # This might happen when trying to upload file names
00123             # with non-ascii characters on Safari.
00124             return _("No file content. Delete non ASCII characters from the file name and try again.")
00125 
00126         filename = request.form['filename']
00127         basepath, basename = os.path.split(filename)
00128         basename, ext = os.path.splitext(basename)
00129         ci = AttachFile.ContainerItem(request, pagename, target)
00130         filecontent = file_upload.stream
00131         content_length = None
00132         if ext == '.draw': # TWikiDraw POSTs this first
00133             AttachFile._addLogEntry(request, 'ATTDRW', pagename, target)
00134             ci.truncate()
00135             filecontent = filecontent.read() # read file completely into memory
00136             filecontent = filecontent.replace("\r", "")
00137         elif ext == '.map':
00138             # touch attachment directory to invalidate cache if new map is saved
00139             attach_dir = AttachFile.getAttachDir(request, pagename)
00140             os.utime(attach_dir, None)
00141             filecontent = filecontent.read() # read file completely into memory
00142             filecontent = filecontent.strip()
00143         else:
00144             #content_length = file_upload.content_length
00145             # XXX gives -1 for wsgiref :( If this is fixed, we could use the file obj,
00146             # without reading it into memory completely:
00147             filecontent = filecontent.read()
00148 
00149         ci.put('drawing' + ext, filecontent, content_length)
00150 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 187 of file twikidraw.py.

Definition at line 188 of file twikidraw.py.

Definition at line 192 of file twikidraw.py.

Definition at line 106 of file twikidraw.py.

Definition at line 190 of file twikidraw.py.

Definition at line 189 of file twikidraw.py.

Definition at line 105 of file twikidraw.py.

Definition at line 191 of file twikidraw.py.

Definition at line 107 of file twikidraw.py.

string MoinMoin.action.twikidraw.TwikiDraw.title = "%s %s:%s" [static]

Definition at line 195 of file twikidraw.py.


The documentation for this class was generated from the following file: