Back to index

moin  1.9.0~rc2
Functions
MoinMoin.action.backup Namespace Reference

Functions

def addFiles
def sendBackup
def sendBackupForm
def sendMsg
def backupAllowed
def execute

Function Documentation

def MoinMoin.action.backup.addFiles (   path,
  tar,
  exclude_func 
)
Add files in path to tar 

Definition at line 25 of file backup.py.

00025 
00026 def addFiles(path, tar, exclude_func):
00027     """ Add files in path to tar """
00028     for root, dirs, files in os.walk(path):
00029         files.sort() # sorted page revs may compress better
00030         for name in files:
00031             path = os.path.join(root, name)
00032             if exclude_func(path):
00033                 continue
00034             tar.add(path)
00035 

Here is the caller graph for this function:

Return True if backup is allowed 

Definition at line 90 of file backup.py.

00090 
00091 def backupAllowed(request):
00092     """ Return True if backup is allowed """
00093     action = __name__.split('.')[-1]
00094     user = request.user
00095     return user.valid and user.name in request.cfg.backup_users
00096 

Here is the caller graph for this function:

def MoinMoin.action.backup.execute (   pagename,
  request 
)

Definition at line 97 of file backup.py.

00097 
00098 def execute(pagename, request):
00099     _ = request.getText
00100     if not backupAllowed(request):
00101         return sendMsg(request, pagename,
00102                        msg=_('You are not allowed to do remote backup.'), msgtype="error")
00103 
00104     dowhat = request.form.get('do')
00105     if dowhat == 'backup':
00106         sendBackup(request)
00107     elif dowhat is None:
00108         sendBackupForm(request, pagename)
00109     else:
00110         return sendMsg(request, pagename,
00111                        msg=_('Unknown backup subaction: %s.') % dowhat, msgtype="error")
00112 

Here is the call graph for this function:

Send compressed tar file 

Definition at line 36 of file backup.py.

00036 
00037 def sendBackup(request):
00038     """ Send compressed tar file """
00039     dateStamp = time.strftime("%Y-%m-%d--%H-%M-%S-UTC", time.gmtime())
00040     filename = "%s-%s.tar.%s" % (request.cfg.siteid, dateStamp, request.cfg.backup_compression)
00041     request.content_type = 'application/octet-stream'
00042     request.headers.add('Content-Disposition', 'inline; filename="%s"' % filename)
00043     tar = tarfile.open(fileobj=request, mode="w|%s" % request.cfg.backup_compression)
00044     # allow GNU tar's longer file/pathnames
00045     tar.posix = False
00046     for path in request.cfg.backup_include:
00047         addFiles(path, tar, request.cfg.backup_exclude)
00048     tar.close()
00049 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.action.backup.sendBackupForm (   request,
  pagename 
)

Definition at line 50 of file backup.py.

00050 
00051 def sendBackupForm(request, pagename):
00052     _ = request.getText
00053     request.setContentLanguage(request.lang)
00054     title = _('Wiki Backup')
00055     request.theme.send_title(title, pagename=pagename)
00056     request.write(request.formatter.startContent("content"))
00057 
00058     request.write(_("""= Downloading a backup =
00059 
00060 Please note:
00061  * Store backups in a safe and secure place - they contain sensitive information.
00062  * Make sure your wiki configuration backup_* values are correct and complete.
00063  * Make sure the backup file you get contains everything you need in case of problems.
00064  * Make sure it is downloaded without problems.
00065 
00066 To get a backup, just click here:""", wiki=True))
00067 
00068     request.write("""
00069 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
00070 <input type="hidden" name="action" value="backup">
00071 <input type="hidden" name="do" value="backup">
00072 <input type="submit" value="%(backup_button)s">
00073 </form>
00074 """ % {
00075     'baseurl': request.script_root,
00076     'pagename': wikiutil.quoteWikinameURL(pagename),
00077     'backup_button': _('Backup'),
00078 })
00079 
00080     request.write(request.formatter.endContent())
00081     request.theme.send_footer(pagename)
00082     request.theme.send_closing_html()
00083 

Here is the caller graph for this function:

def MoinMoin.action.backup.sendMsg (   request,
  pagename,
  msg,
  msgtype 
)

Definition at line 84 of file backup.py.

00084 
00085 def sendMsg(request, pagename, msg, msgtype):
00086     from MoinMoin import Page
00087     request.theme.add_msg(msg, msgtype)
00088     return Page.Page(request, pagename).send_page()
00089 

Here is the caller graph for this function: