Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.action.anywikidraw.AnyWikiDraw Class Reference
Collaboration diagram for MoinMoin.action.anywikidraw.AnyWikiDraw:
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 pageurl = wikiutil.escape(pageurl, 1)
tuple saveurl = wikiutil.escape(saveurl, 1)
string title = '%s %s:%s'

Detailed Description

anywikidraw action 

Definition at line 81 of file anywikidraw.py.


Constructor & Destructor Documentation

def MoinMoin.action.anywikidraw.AnyWikiDraw.__init__ (   self,
  request,
  pagename,
  target 
)

Definition at line 83 of file anywikidraw.py.

00083 
00084     def __init__(self, request, pagename, target):
00085         self.request = request
00086         self.pagename = pagename
00087         self.target = target


Member Function Documentation

Definition at line 131 of file anywikidraw.py.

00131 
00132     def render(self):
00133         request = self.request
00134         _ = request.getText
00135         pagename = self.pagename
00136         target = self.target
00137         if not request.user.may.read(pagename):
00138             return _('You are not allowed to view attachments of this page.')
00139         if not target:
00140             return _("Empty target name given.")
00141 
00142         ci = AttachFile.ContainerItem(request, pagename, target)
00143         if ci.exists():
00144             drawurl = ci.member_url('drawing.svg')
00145         else:
00146             drawurl = ''
00147         pageurl = request.href(pagename)
00148         saveurl = request.href(pagename, action=action_name, do='save', target=target)
00149         helpurl = request.href("HelpOnActions/AttachFile")
00150 
00151         html = """
00152 <p>
00153 <applet code="org.anywikidraw.moinmoin.MoinMoinDrawingApplet.class" codebase="."
00154         archive="%(htdocs)s/applets/anywikidraw/lib/AnyWikiDrawForMoinMoin.jar" width="800" height="620">
00155 
00156     <!-- The following parameters are used to tell AnyWikiDraw how to communicate with MoinMoin. -->
00157     <param name="DrawingName" value="%(basename)s.svg">
00158     <param name="DrawingURL" value="%(drawurl)s">
00159     <param name="PageURL" value="%(pageurl)s">
00160     <param name="UploadURL" value="%(saveurl)s">
00161 
00162     <!-- The following parameters are used to configure the drawing applet -->
00163     <param name="Locale" value="en">
00164 
00165     <!-- The following parameters are used to configure Sun's Java Plug-In -->
00166     <param name="codebase_lookup" value="false">
00167     <param name="classloader_cache" value="false">
00168     <!-- The following makes trouble with FF3 on Ubuntu 9.04 as client and
00169          Apache2 / mod_wsgi on Debian Lenny as server, it seems to confuse
00170          .gz files with gzip content-encoding and fails miserably somehow:
00171          param name="java_arguments" value="-Djnlp.packEnabled=true" -->
00172     <param name="boxborder" value="false">
00173     <param name="centerimage" value="true">
00174     <strong>NOTE:</strong> You need a Java enabled browser to edit the drawing.
00175 </applet>
00176 </p>
""" % dict(

Definition at line 88 of file anywikidraw.py.

00088 
00089     def save(self):
00090         request = self.request
00091         _ = request.getText
00092         pagename = self.pagename
00093         target = self.target
00094         if not request.user.may.write(pagename):
00095             return _('You are not allowed to save a drawing on this page.')
00096         if not target:
00097             return _("Empty target name given.")
00098 
00099         file_upload = request.files.get('filepath')
00100         if not file_upload:
00101             # This might happen when trying to upload file names
00102             # with non-ascii characters on Safari.
00103             return _("No file content. Delete non ASCII characters from the file name and try again.")
00104 
00105         filename = request.form['filename']
00106         basepath, basename = os.path.split(filename)
00107         basename, ext = os.path.splitext(basename)
00108 
00109         ci = AttachFile.ContainerItem(request, pagename, target)
00110         filecontent = file_upload.stream
00111         content_length = None
00112         if ext == '.svg': # AnyWikiDraw POSTs this first
00113             AttachFile._addLogEntry(request, 'ATTDRW', pagename, target)
00114             ci.truncate()
00115             filecontent = filecontent.read() # read file completely into memory
00116             filecontent = filecontent.replace("\r", "")
00117         elif ext == '.map':
00118             # touch attachment directory to invalidate cache if new map is saved
00119             attach_dir = AttachFile.getAttachDir(request, pagename)
00120             os.utime(attach_dir, None)
00121             filecontent = filecontent.read() # read file completely into memory
00122             filecontent = filecontent.strip()
00123         else:
00124             #content_length = file_upload.content_length
00125             # XXX gives -1 for wsgiref :( If this is fixed, we could use the file obj,
00126             # without reading it into memory completely:
00127             filecontent = filecontent.read()
00128 
00129         if filecontent:
00130             ci.put('drawing' + ext, filecontent, content_length)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 178 of file anywikidraw.py.

Definition at line 179 of file anywikidraw.py.

Definition at line 85 of file anywikidraw.py.

Definition at line 180 of file anywikidraw.py.

Definition at line 84 of file anywikidraw.py.

Definition at line 181 of file anywikidraw.py.

Definition at line 86 of file anywikidraw.py.

string MoinMoin.action.anywikidraw.AnyWikiDraw.title = '%s %s:%s' [static]

Definition at line 184 of file anywikidraw.py.


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