mirror of https://github.com/tLDP/LDP
Display filemode as a string, not a decimal value. Closes #89710
Write docfiles table using WOStringIO().
This commit is contained in:
parent
b51361e702
commit
4ef9d4c53a
|
@ -176,6 +176,26 @@ def trim(astring):
|
|||
temp = str(astring)
|
||||
return temp.strip()
|
||||
|
||||
# This will be tested in the order listed
|
||||
FILEMODE_MASKS = ((0400, 'r'),
|
||||
(0200, 'w'),
|
||||
(0100, 'x'),
|
||||
(0040, 'r'),
|
||||
(0020, 'w'),
|
||||
(0010, 'x'),
|
||||
(0004, 'r'),
|
||||
(0002, 'w'),
|
||||
(0001, 'x'))
|
||||
|
||||
def octal2permission(filemode):
|
||||
symbolic = ''
|
||||
for mask in FILEMODE_MASKS:
|
||||
if filemode & mask[0]:
|
||||
symbolic += mask[1]
|
||||
else:
|
||||
symbolic += '-'
|
||||
return symbolic
|
||||
|
||||
class WOStringIO:
|
||||
"""
|
||||
Write-Only pure python extra fast buffer.
|
||||
|
|
|
@ -34,8 +34,8 @@ from URLParse import URI
|
|||
from DataLayer import *
|
||||
from SourceFiles import sourcefiles
|
||||
from WebLayer import lampadasweb
|
||||
from Widgets import widgets
|
||||
from Tables import tables
|
||||
from Widgets import widgets
|
||||
from Lintadas import lintadas
|
||||
from Sessions import sessions
|
||||
import commands
|
||||
|
|
|
@ -85,7 +85,7 @@ class SourceFile:
|
|||
self.dtd_code = ''
|
||||
self.dtd_version = ''
|
||||
self.filesize = 0
|
||||
self.filemode = ''
|
||||
self.filemode = 0
|
||||
self.modified = ''
|
||||
self.errors = FileErrs()
|
||||
self.errors.filename = filename
|
||||
|
@ -107,7 +107,7 @@ class SourceFile:
|
|||
self.dtd_version = trim(row[3])
|
||||
self.calc_local()
|
||||
self.filesize = safeint(row[4])
|
||||
self.filemode = trim(row[5])
|
||||
self.filemode = safeint(row[5])
|
||||
self.modified = time2str(row[6])
|
||||
self.file_only = os.path.split(self.filename)[1]
|
||||
self.basename = os.path.splitext(self.file_only)[0]
|
||||
|
|
|
@ -180,73 +180,71 @@ class Tables:
|
|||
log(3, 'Creating docfiles table')
|
||||
doc = lampadas.docs[uri.id]
|
||||
|
||||
box = '''
|
||||
<table class="box" width="100%">
|
||||
<tr><th colspan="6">|strdocfiles|</th></tr>
|
||||
'''
|
||||
box = WOStringIO('''<table class="box" width="100%%">
|
||||
<tr><th colspan="6">%s</th></tr>
|
||||
''' % ('|strdocfiles|'))
|
||||
doc = lampadas.docs[uri.id]
|
||||
keys = doc.files.sort_by('filename')
|
||||
for key in keys:
|
||||
|
||||
lintadas.check_file(key)
|
||||
docfile = doc.files[key]
|
||||
sourcefile = sourcefiles[key]
|
||||
box = box + '<form method=GET action="/data/save/document_file" name="document_file">'
|
||||
box = box + '<input type=hidden name="doc_id" value=' + str(doc.id) + '>\n'
|
||||
box = box + '<input type=hidden name="filename" size=30 style="width:100%" value="' + docfile.filename + '">\n'
|
||||
box = box + '<tr>\n'
|
||||
box.write('<form method=GET action="/data/save/document_file" name="document_file">')
|
||||
box.write('<input type=hidden name="doc_id" value=' + str(doc.id) + '>\n')
|
||||
box.write('<input type=hidden name="filename" size=30 style="width:100%" value="' + docfile.filename + '">\n')
|
||||
box.write('<tr>\n')
|
||||
if sourcefile.errors.count() > 0:
|
||||
box = box + '<td class="sectionlabel error" colspan="6">' + docfile.filename + '</td>\n'
|
||||
box.write('<td class="sectionlabel error" colspan="6">' + docfile.filename + '</td>\n')
|
||||
else:
|
||||
box = box + '<td class="sectionlabel" colspan="6"><a href="|uri.base|sourcefile/' + docfile.filename + uri.lang_ext + '">' + docfile.filename + '</a></td>\n'
|
||||
box = box + '</tr>\n'
|
||||
box = box + '<tr>\n'
|
||||
box = box + '<th class="label">|strprimary|</th>'
|
||||
box = box + '<td>' + widgets.tf('top', docfile.top, uri.lang) + '</td>\n'
|
||||
box = box + '<th class="label">|strfilesize|</th>'
|
||||
box = box + '<td>' + str(sourcefile.filesize) + '</td>\n'
|
||||
box = box + '<th class="label">|strupdated|</th>'
|
||||
box.write('<td class="sectionlabel" colspan="6"><a href="|uri.base|sourcefile/' + docfile.filename + uri.lang_ext + '">' + docfile.filename + '</a></td>\n')
|
||||
box.write('</tr>\n')
|
||||
box.write('<tr>\n')
|
||||
box.write('<th class="label">|strprimary|</th>')
|
||||
box.write('<td>' + widgets.tf('top', docfile.top, uri.lang) + '</td>\n')
|
||||
box.write('<th class="label">|strfilesize|</th>')
|
||||
box.write('<td>' + str(sourcefile.filesize) + '</td>\n')
|
||||
box.write('<th class="label">|strupdated|</th>')
|
||||
if sourcefile.modified > '':
|
||||
box = box + '<td>' + sourcefile.modified + '</td>\n'
|
||||
box.write('<td>' + sourcefile.modified + '</td>\n')
|
||||
else:
|
||||
box = box + '<td>|strunknown|</td>\n'
|
||||
box = box + '</tr>\n'
|
||||
box = box + '<tr>\n'
|
||||
box = box + '<th class="label">|strformat|</th>'
|
||||
box.write('<td>|strunknown|</td>\n')
|
||||
box.write('</tr>\n')
|
||||
box.write('<tr>\n')
|
||||
box.write('<th class="label">|strformat|</th>')
|
||||
if sourcefile.format_code > '':
|
||||
box = box + '<td>' + lampadas.formats[sourcefile.format_code].name[uri.lang] + '</td>\n'
|
||||
box.write('<td>' + lampadas.formats[sourcefile.format_code].name[uri.lang] + '</td>\n')
|
||||
else:
|
||||
box = box + '<td>|strunknown|</td>\n'
|
||||
box = box + '<th class="label">|strfilemode|</th>'
|
||||
if sourcefile.filemode > '':
|
||||
box = box + '<td>' + str(sourcefile.filemode) + '</td>\n'
|
||||
else:
|
||||
box = box + '<td>|strunknown|</td>\n'
|
||||
box = box + '''
|
||||
box.write('<td>|strunknown|</td>\n')
|
||||
box.write('<th class="label">|strfilemode|</th>')
|
||||
print sourcefile.filemode
|
||||
box.write('<td>' + widgets.filemode(sourcefile.filemode) + '</td>\n')
|
||||
box.write('''
|
||||
<td><input type="checkbox" name="delete">|strdelete|</td>
|
||||
<td><input type="submit" name="action" value="|strsave|"></td>
|
||||
</tr>
|
||||
'''
|
||||
box = box + '</form>'
|
||||
''')
|
||||
box.write('</form>')
|
||||
|
||||
# Add a new docfile
|
||||
box = box + '<tr>\n'
|
||||
box = box + '<form method=GET action="/data/save/newdocument_file" name="document_file">'
|
||||
box = box + '<input name="doc_id" type="hidden" value="' + str(doc.id) + '">\n'
|
||||
box = box + '<td colspan="6"><input type="text" name="filename" size="30" style="width:100%"></td>\n'
|
||||
box = box + '</tr>\n'
|
||||
box = box + '<tr>\n'
|
||||
box = box + '<th class="label">|strprimary|</th>'
|
||||
box = box + '<td>' + widgets.tf('top', 0, uri.lang) + '</td>\n'
|
||||
box = box + '<td></td>\n'
|
||||
box = box + '<td></td>\n'
|
||||
box = box + '<td></td>\n'
|
||||
box = box + '''
|
||||
box.write('<tr>\n')
|
||||
box.write('<form method=GET action="/data/save/newdocument_file" name="document_file">')
|
||||
box.write('<input name="doc_id" type="hidden" value="' + str(doc.id) + '">\n')
|
||||
box.write('<td colspan="6"><input type="text" name="filename" size="30" style="width:100%"></td>\n')
|
||||
box.write('</tr>\n')
|
||||
box.write('<tr>\n')
|
||||
box.write('<th class="label">|strprimary|</th>')
|
||||
box.write('<td>' + widgets.tf('top', 0, uri.lang) + '</td>\n')
|
||||
box.write('<td></td>\n')
|
||||
box.write('<td></td>\n')
|
||||
box.write('<td></td>\n')
|
||||
box.write('''
|
||||
<td><input type="submit" name="action" value="|stradd|"></td>
|
||||
</tr>
|
||||
</form>
|
||||
'''
|
||||
box = box + '</table>\n'
|
||||
return box
|
||||
''')
|
||||
box.write('</table>\n')
|
||||
return box.get_value()
|
||||
|
||||
|
||||
def docusers(self, uri):
|
||||
|
|
|
@ -300,4 +300,10 @@ class Widgets:
|
|||
combo.write("</select>")
|
||||
return combo.get_value()
|
||||
|
||||
def filemode(self, value):
|
||||
if value > 0:
|
||||
return WOStringIO(octal2permission(value)).get_value()
|
||||
else:
|
||||
return '|strunknown|'
|
||||
|
||||
widgets = Widgets()
|
||||
|
|
Loading…
Reference in New Issue