[Moin-devel] CVS: MoinMoin PageEditor.py,1.6,1.7 cgimain.py,1.52,1.53 request.py,1.6,1.7 userform.py,1.16,1.17 wikiaction.py,1.71,1.72 wikimacro.py,1.39,1.40 wikiutil.py,1.95,1.96
J?rgen Hermann
jhermann at users.sourceforge.net
Wed Apr 24 13:40:34 EDT 2002
Update of /cvsroot/moin/MoinMoin
In directory usw-pr-cvs1:/tmp/cvs-serv32698
Modified Files:
PageEditor.py cgimain.py request.py userform.py wikiaction.py
wikimacro.py wikiutil.py
Log Message:
Replaced most refs to user.current by request.user
Index: PageEditor.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/PageEditor.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** PageEditor.py 17 Apr 2002 21:58:16 -0000 1.6
--- PageEditor.py 24 Apr 2002 20:11:21 -0000 1.7
***************
*** 48,52 ****
# check edit permissions
! if not user.current.may.edit:
self.send_page(request,
msg=_("""<b>You are not allowed to edit any pages.</b>"""))
--- 48,52 ----
# check edit permissions
! if not request.user.may.edit:
self.send_page(request,
msg=_("""<b>You are not allowed to edit any pages.</b>"""))
***************
*** 91,100 ****
except StandardError:
text_rows = config.edit_rows
! if user.current.valid: text_rows = int(user.current.edit_rows)
try:
text_cols = int(form['cols'].value)
except StandardError:
text_cols = 80
! if user.current.valid: text_cols = int(user.current.edit_cols)
print '<form method="post" action="%s/%s%s">' % (
--- 91,100 ----
except StandardError:
text_rows = config.edit_rows
! if request.user.valid: text_rows = int(request.user.edit_rows)
try:
text_cols = int(form['cols'].value)
except StandardError:
text_cols = 80
! if request.user.valid: text_cols = int(request.user.edit_cols)
print '<form method="post" action="%s/%s%s">' % (
***************
*** 239,243 ****
emails = []
for uid in userlist:
! if uid == user.current.id: continue # no self notification
subscriber = user.User(uid)
if not subscriber.email: continue # skip empty email address
--- 239,243 ----
emails = []
for uid in userlist:
! if uid == request.user.id: continue # no self notification
subscriber = user.User(uid)
if not subscriber.email: continue # skip empty email address
***************
*** 255,259 ****
"The following page has been changed by %(editor)s:\n"
"%(pagelink)s\n\n") % {
! 'editor': user.current.name or os.environ.get('REMOTE_ADDR', "<unknown>"),
'pagelink': webapi.getQualifiedURL(self.url()),
'sitename': config.sitename or webapi.getBaseURL(),
--- 255,259 ----
"The following page has been changed by %(editor)s:\n"
"%(pagelink)s\n\n") % {
! 'editor': request.user.name or os.environ.get('REMOTE_ADDR', "<unknown>"),
'pagelink': webapi.getQualifiedURL(self.url()),
'sitename': config.sitename or webapi.getBaseURL(),
***************
*** 285,289 ****
'pagename': self.page_name,
},
! mailBody, mail_from=user.current.email)
return msg
--- 285,289 ----
'pagename': self.page_name,
},
! mailBody, mail_from=request.user.email)
return msg
***************
*** 291,295 ****
! def _user_variable(self):
"""If user has a profile return the user name from the profile
else return the remote address or "anonymous"
--- 291,295 ----
! def _user_variable(self, request):
"""If user has a profile return the user name from the profile
else return the remote address or "anonymous"
***************
*** 298,302 ****
links to the wiki user homepage (if one exists).
"""
! username = user.current.name
if username and config.allow_extended_names and \
string.count(username, ' ') and Page(username).exists():
--- 298,302 ----
links to the wiki user homepage (if one exists).
"""
! username = request.user.name
if username and config.allow_extended_names and \
string.count(username, ' ') and Page(username).exists():
***************
*** 305,309 ****
! def _expand_variables(self, text):
"""Expand @VARIABLE@ in `text`and return the expanded text."""
#!!! TODO: Allow addition of variables via moin_config (and/or a text file)
--- 305,309 ----
! def _expand_variables(self, request, text):
"""Expand @VARIABLE@ in `text`and return the expanded text."""
#!!! TODO: Allow addition of variables via moin_config (and/or a text file)
***************
*** 312,323 ****
'TIME': lambda t=now: "[[DateTime(%s)]]" % t,
'DATE': lambda t=now: "[[Date(%s)]]" % t,
! 'USERNAME': lambda s=self: s._user_variable(),
! 'USER': lambda s=self: "-- %s" % (s._user_variable(),),
! 'SIG': lambda s=self, t=now: "-- %s [[DateTime(%s)]]"
! % (s._user_variable(), t,),
}
! if user.current.valid and user.current.name and user.current.email:
! system_vars['MAILTO'] = lambda u=user.current: \
"[mailto:%s %s]" % (u.email, u.name)
#!!! TODO: Use a more stream-lined re.sub algorithm
--- 312,323 ----
'TIME': lambda t=now: "[[DateTime(%s)]]" % t,
'DATE': lambda t=now: "[[Date(%s)]]" % t,
! 'USERNAME': lambda s=self, r=request: s._user_variable(r),
! 'USER': lambda s=self, r=request: "-- %s" % (s._user_variable(r),),
! 'SIG': lambda s=self, r=request, t=now: "-- %s [[DateTime(%s)]]"
! % (s._user_variable(r), t,),
}
! if request.user.valid and request.user.name and request.user.email:
! system_vars['MAILTO'] = lambda u=request.user: \
"[mailto:%s %s]" % (u.email, u.name)
#!!! TODO: Use a more stream-lined re.sub algorithm
***************
*** 371,375 ****
"""
msg = ""
! if not user.current.may.edit:
msg = _("""<b>You are not allowed to edit any pages.</b>""")
if not newtext:
--- 371,375 ----
"""
msg = ""
! if not request.user.may.edit:
msg = _("""<b>You are not allowed to edit any pages.</b>""")
if not newtext:
***************
*** 409,413 ****
if not (wikiutil.isTemplatePage(self.page_name) or
wikiutil.isFormPage(self.page_name)):
! newtext = self._expand_variables(newtext)
# write the page file
--- 409,413 ----
if not (wikiutil.isTemplatePage(self.page_name) or
wikiutil.isFormPage(self.page_name)):
! newtext = self._expand_variables(request, newtext)
# write the page file
Index: cgimain.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/cgimain.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -r1.52 -r1.53
*** cgimain.py 17 Apr 2002 21:58:16 -0000 1.52
--- cgimain.py 24 Apr 2002 20:11:21 -0000 1.53
***************
*** 113,116 ****
--- 113,119 ----
request.clock.stop('imports')
+ # !!! if all refs to user.current are removed, create the user together with the request instance
+ request.user = user.current
+
# sys.stderr.write("----\n")
# for key in os.environ.keys():
***************
*** 135,140 ****
# possibly jump to page where user left off
! if not pagename and not action and user.current.remember_last_visit:
! pagetrail = user.current.getTrail()
if pagetrail:
webapi.http_redirect(request, Page(pagetrail[-1]).url())
--- 138,143 ----
# possibly jump to page where user left off
! if not pagename and not action and request.user.remember_last_visit:
! pagetrail = request.user.getTrail()
if pagetrail:
webapi.http_redirect(request, Page(pagetrail[-1]).url())
Index: request.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/request.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** request.py 24 Apr 2002 19:36:54 -0000 1.6
--- request.py 24 Apr 2002 20:11:21 -0000 1.7
***************
*** 44,47 ****
--- 44,48 ----
from MoinMoin import i18n
+ self.user = None
self.form = None
self.pragma = {}
Index: userform.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/userform.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** userform.py 17 Apr 2002 21:58:16 -0000 1.16
--- userform.py 24 Apr 2002 20:11:21 -0000 1.17
***************
*** 47,51 ****
cookie['MOIN_ID'].value, webapi.getScriptname(),))
os.environ['HTTP_COOKIE'] = ''
! user.current = user.User()
return _("<b>Cookie deleted!</b>")
--- 47,52 ----
cookie['MOIN_ID'].value, webapi.getScriptname(),))
os.environ['HTTP_COOKIE'] = ''
! request.user = user.User()
! user.current = request.user
return _("<b>Cookie deleted!</b>")
***************
*** 95,98 ****
--- 96,100 ----
# send the cookie
theuser.sendCookie(request)
+ request.user = theuser
user.current = theuser
else:
***************
*** 202,205 ****
--- 204,208 ----
theuser.save()
theuser.sendCookie(request)
+ request.user = theuser
user.current = theuser
***************
*** 251,255 ****
! def getUserForm(form):
# Note that this form is NOT designed for security, just to have a cookie
# with name & email; do not base security measures on this!
--- 254,260 ----
! def getUserForm(request):
! form = request.form
!
# Note that this form is NOT designed for security, just to have a cookie
# with name & email; do not base security measures on this!
***************
*** 310,322 ****
for option, text in _date_formats.items():
dtfmt_select = dtfmt_select + '<option value="%s"%s>%s' % (
! option, ('', ' selected')[user.current.datetime_fmt == text], text)
! if user.current.valid:
! html_uid = '<tr><td><b>ID</b> </td><td>%s</td></tr>' % (user.current.id,)
html_button = """
<input type="submit" name="save" value="%s">
<input type="submit" name="logout" value="%s">
""" % (_(' Save '), _(' Logout '))
! url = "%s?action=userform&uid=%s" % (webapi.getBaseURL(), user.current.id)
html_relogin = _('To login on a different machine, use this URL: ') + \
'<a href="%s">%s</a><br>' % (url, url)
--- 315,327 ----
for option, text in _date_formats.items():
dtfmt_select = dtfmt_select + '<option value="%s"%s>%s' % (
! option, ('', ' selected')[request.user.datetime_fmt == text], text)
! if request.user.valid:
! html_uid = '<tr><td><b>ID</b> </td><td>%s</td></tr>' % (request.user.id,)
html_button = """
<input type="submit" name="save" value="%s">
<input type="submit" name="logout" value="%s">
""" % (_(' Save '), _(' Logout '))
! url = "%s?action=userform&uid=%s" % (webapi.getBaseURL(), request.user.id)
html_relogin = _('To login on a different machine, use this URL: ') + \
'<a href="%s">%s</a><br>' % (url, url)
***************
*** 341,349 ****
notify = ""
if config.mail_smarthost:
! notifylist = user.current.getSubscriptionList()
notifylist.sort()
warning = ""
! if not user.current.email:
warning = '<br/><font color="#FF4040"><small>' + \
_("This list does not work, unless you have entered a valid email address!") + \
--- 346,354 ----
notify = ""
if config.mail_smarthost:
! notifylist = request.user.getSubscriptionList()
notifylist.sort()
warning = ""
! if not request.user.email:
warning = '<br/><font color="#FF4040"><small>' + \
_("This list does not work, unless you have entered a valid email address!") + \
***************
*** 367,379 ****
'relogin': html_relogin,
'now': time.strftime(config.datetime_fmt, time.localtime(time.time())),
! 'tz_select': _tz_select(user.current),
'dtfmt_select': dtfmt_select,
! 'language_select': _lang_select(user.current),
'notify': notify,
! 'quicklinklist': string.join(user.current.getQuickLinks(), '\n'),
}
! if not user.current.css_url:
! user.current.css_url = config.css_url
data['checkbox_fields'] = ''
--- 372,384 ----
'relogin': html_relogin,
'now': time.strftime(config.datetime_fmt, time.localtime(time.time())),
! 'tz_select': _tz_select(request.user),
'dtfmt_select': dtfmt_select,
! 'language_select': _lang_select(request.user),
'notify': notify,
! 'quicklinklist': string.join(request.user.getQuickLinks(), '\n'),
}
! if not request.user.css_url:
! request.user.css_url = config.css_url
data['checkbox_fields'] = ''
***************
*** 383,390 ****
data['checkbox_fields'] = data['checkbox_fields'] + \
'<input type="checkbox" name="%s" value="1"%s> %s<br>' % (
! key, ('', ' checked')[getattr(user.current, key, 0)], label())
data.update(formtext)
! data.update(vars(user.current))
result = htmlform % data
--- 388,395 ----
data['checkbox_fields'] = data['checkbox_fields'] + \
'<input type="checkbox" name="%s" value="1"%s> %s<br>' % (
! key, ('', ' checked')[getattr(request.user, key, 0)], label())
data.update(formtext)
! data.update(vars(request.user))
result = htmlform % data
Index: wikiaction.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/wikiaction.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -r1.71 -r1.72
*** wikiaction.py 24 Apr 2002 19:36:54 -0000 1.71
--- wikiaction.py 24 Apr 2002 20:11:21 -0000 1.72
***************
*** 218,223 ****
# Show date info
print _('<b>Differences between version dated %s and %s') % (
! user.current.getFormattedDateTime(os.path.getmtime(backup_file)),
! user.current.getFormattedDateTime(os.path.getmtime(page_file)))
if edit_count != 1:
print _(' (spanning %d versions)') % (edit_count,)
--- 218,223 ----
# Show date info
print _('<b>Differences between version dated %s and %s') % (
! request.user.getFormattedDateTime(os.path.getmtime(backup_file)),
! request.user.getFormattedDateTime(os.path.getmtime(page_file)))
if edit_count != 1:
print _(' (spanning %d versions)') % (edit_count,)
***************
*** 230,234 ****
del lines[0]
! if user.current.show_fancy_diff:
print '<div class="diffold">' + _('Deletions are marked like this.') + '</div>'
print '<div class="diffnew">' + _('Additions are marked like this.') + '</div>'
--- 230,234 ----
del lines[0]
! if request.user.show_fancy_diff:
print '<div class="diffold">' + _('Deletions are marked like this.') + '</div>'
print '<div class="diffnew">' + _('Additions are marked like this.') + '</div>'
***************
*** 347,351 ****
print '<tr><td align="right">%d</td><td align="right"> %s</td><td align="right"> %d</td>' % (
count,
! user.current.getFormattedDateTime(st[ST_MTIME]),
st[ST_SIZE])
--- 347,351 ----
print '<tr><td align="right">%d</td><td align="right"> %s</td><td align="right"> %d</td>' % (
count,
! request.user.getFormattedDateTime(st[ST_MTIME]),
st[ST_SIZE])
***************
*** 452,456 ****
# check whether the user has a profile
! elif not user.current.valid:
msg = _('''
<b>You didn't create a user profile yet.<br>
--- 452,456 ----
# check whether the user has a profile
! elif not request.user.valid:
msg = _('''
<b>You didn't create a user profile yet.<br>
***************
*** 459,463 ****
# check whether the user has an email address
! elif not user.current.email:
msg = _('''
<b>You didn't enter an email address in your profile.<br>
--- 459,463 ----
# check whether the user has an email address
! elif not request.user.email:
msg = _('''
<b>You didn't enter an email address in your profile.<br>
***************
*** 467,471 ****
# check whether already subscribed
! elif user.current.isSubscribedTo([pagename]):
msg = _('<b>You are already subscribed to this page.</b>') + \
_('''<br>
--- 467,471 ----
# check whether already subscribed
! elif request.user.isSubscribedTo([pagename]):
msg = _('<b>You are already subscribed to this page.</b>') + \
_('''<br>
***************
*** 476,481 ****
# subscribe to current page
else:
! if user.current.subscribePage(pagename):
! user.current.save()
msg = _('<b>You have been subscribed to this page.</b>') + \
_('''<br>
--- 476,481 ----
# subscribe to current page
else:
! if request.user.subscribePage(pagename):
! request.user.save()
msg = _('<b>You have been subscribed to this page.</b>') + \
_('''<br>
***************
*** 502,506 ****
tm = time.time()
! user.current.setBookmark(tm)
Page(pagename).send_page(request)
--- 502,506 ----
tm = time.time()
! request.user.setBookmark(tm)
Page(pagename).send_page(request)
***************
*** 553,557 ****
def do_rss_rc(pagename, request):
from MoinMoin.macro import RecentChanges
! RecentChanges.rss(pagename, request.form)
--- 553,557 ----
def do_rss_rc(pagename, request):
from MoinMoin.macro import RecentChanges
! RecentChanges.rss(pagename, request)
Index: wikimacro.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/wikimacro.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** wikimacro.py 17 Apr 2002 21:58:16 -0000 1.39
--- wikimacro.py 24 Apr 2002 20:11:21 -0000 1.40
***************
*** 315,327 ****
def _macro_Date(self, args):
! return self.__get_Date(args, user.current.getFormattedDate)
def _macro_DateTime(self, args):
! return self.__get_Date(args, user.current.getFormattedDateTime)
def _macro_UserPreferences(self, args):
from MoinMoin import userform
! return self.formatter.rawHTML(userform.getUserForm(self.form))
def _macro_Anchor(self, args):
--- 315,327 ----
def _macro_Date(self, args):
! return self.__get_Date(args, self.request.user.getFormattedDate)
def _macro_DateTime(self, args):
! return self.__get_Date(args, self.request.user.getFormattedDateTime)
def _macro_UserPreferences(self, args):
from MoinMoin import userform
! return self.formatter.rawHTML(userform.getUserForm(self.request))
def _macro_Anchor(self, args):
Index: wikiutil.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/wikiutil.py,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -r1.95 -r1.96
*** wikiutil.py 24 Apr 2002 19:36:54 -0000 1.95
--- wikiutil.py 24 Apr 2002 20:11:21 -0000 1.96
***************
*** 72,76 ****
def getSmiley(text, formatter):
! if user.current.show_emoticons:
w, h, img = smileys[string.strip(text)]
return formatter.image(
--- 72,76 ----
def getSmiley(text, formatter):
! if formatter.request.user.show_emoticons:
w, h, img = smileys[string.strip(text)]
return formatter.image(
***************
*** 640,644 ****
print link_tag(quoteWikiname(pagename), _("ShowText"))
print _('of this page'), '<br>'
! if keywords.get('editable', 1) and user.current.may.edit:
print link_tag(quoteWikiname(pagename)+'?action=edit', _('EditText'))
print _('of this page')
--- 640,644 ----
print link_tag(quoteWikiname(pagename), _("ShowText"))
print _('of this page'), '<br>'
! if keywords.get('editable', 1) and request.user.may.edit:
print link_tag(quoteWikiname(pagename)+'?action=edit', _('EditText'))
print _('of this page')
More information about the Moin-devel
mailing list