hors connexion:

- documentation du profiling
 - profiling dans un fichier dépendant du fichier accédé
 - corrections à la gestion des heures dans les rendez-vous et calendriers
 - système de cache pour les templates TAL
   (faire glasnost-ctl compile-tal templates/)
 - etc.
This commit is contained in:
fpeters 2003-09-28 16:24:14 +00:00
parent 4b45ea5a56
commit b6cefbc06b
27 changed files with 207 additions and 201 deletions

View File

@ -100,6 +100,10 @@ DisableSpellchecking:
GettextDomains:
Allows to add more gettext domains to look in for translations.
Profiling:
Dumps profiling informations into /tmp/glasnost-web.prof
(default: false)
ShowFullListInSelectIdForServerRoles:
Define the server roles for which the whole list should appear in SelectId
<select> widgets (instead of the last visited objects).

View File

@ -93,8 +93,8 @@ ServerPort = %(port)s + 13
#experimental# [ContactsServer]
#experimental# ServerPort = %(port)s + 15
#experimental# [DataflowsServer]
#experimental# ServerPort = %(port)s + 16
[DataflowsServer]
ServerPort = %(port)s + 16
#experimental# [DirectoriesServer]
#experimental# ServerPort = %(port)s + 17
@ -150,8 +150,8 @@ ServerPort = %(port)s + 33
#monitoring# [SystemFilesServer]
#monitoring# ServerPort = %(port)s + 34
[TasksServer]
ServerPort = %(port)s + 35
#[TasksServer]
#ServerPort = %(port)s + 35
[TranslationsServer]
ServerPort = %(port)s + 36

View File

@ -47,6 +47,8 @@ __version__ = '$Revision$'[11:-2]
import time
import calendar
import glasnost.web.calendaring as calendaring
def monthTupleJS(year = 0, month = 0):
if not year or not month:
year, month = time.gmtime(time.time())[:2]
@ -69,16 +71,13 @@ def monthTupleJS(year = 0, month = 0):
return cal
def getDayLabels():
return ( N_('Monday'), N_('Tuesday'), N_('Wednesday'), N_('Thursday'),
N_('Friday'), N_('Saturday'), N_('Sunday') )
return calendaring.dayLabels
def getMonthYear(year = 0, month = 0):
if not year or not month:
year, month = time.gmtime(time.time())[:2]
year, month = int(year), int(month)
monthNames = (N_('January'), N_('February'), N_('March'), N_('April'),
N_('May'), N_('June'), N_('July'), N_('August'), N_('September'),
N_('October'), N_('November'), N_('December') )
monthNames = calendaring.montLabels
return '%s %s' % (_(monthNames[month-1]), year)
def getPreviousMonth(year = 0, month = 0):

View File

@ -1279,6 +1279,6 @@ if webTools.getConfig('Profiling', 'false') == 'true':
globals(), locals())
except SystemExit:
pass
prof.dump_stats('/tmp/glasnost-web.prof')
prof.dump_stats('/tmp/glasnost-web-%s.prof'%os.path.split(req.filename)[1])
return result

View File

@ -1,11 +1,31 @@
#! /bin/sh
rm -rf root-system && mkdir root-system
make system PREFIX=`pwd`/root-system/usr/local \
VARPREFIX=`pwd`/root-system/var/lib/ \
ETC_DIR=`pwd`/root-system/etc/glasnost-system \
LOGPREFIX=`pwd`/root-system/var/log \
SERVER_USER=`id -u` SERVER_GROUP=`id -u` \
WEB_USER=`id -u` WEB_GROUP=`id -u` < /dev/null
#rm -rf root-system
ROOT_SBIN=root-system/usr/local/sbin/
if [ -d root-system ]
then
echo "Removing old glasnost://system environment..."
rm -rf root-system
fi
echo "Installing glasnost://system environment in root-system/"
make config-system install \
GLASNOST=glasnost-system PORT=8500 \
PREFIX=`pwd`/root-system/usr/local \
VARPREFIX=`pwd`/root-system/var/lib/ \
ETC_DIR=`pwd`/root-system/etc/glasnost-system \
LOGPREFIX=`pwd`/root-system/var/log \
SERVER_USER=`id -u` SERVER_GROUP=`id -u` \
WEB_USER=`id -u` WEB_GROUP=`id -u` &> /dev/null
$ROOT_SBIN/glasnost-system-ctl start
(cd tmp-system && ./generate-system.py) < /dev/null
$ROOT_SBIN/glasnost-system-ctl stop
echo "Creating system/data"
$ROOT_SBIN/glasnost-system-ctl make-system localhost
rm -rf system/data
cp -rp root-system/var/lib/glasnost-system/system system/data
find system/data/ -type d | xargs chmod 755
find system/data/ -type f | xargs chmod 644

View File

@ -1,10 +1,23 @@
#! /bin/sh
rm -rf root-tests && mkdir root-tests
make tests PREFIX=`pwd`/root-tests/usr/local \
VARPREFIX=`pwd`/root-tests/var/lib/ \
ETC_DIR=`pwd`/root-tests/etc/glasnost-tests \
LOGPREFIX=`pwd`/root-tests/var/log \
SERVER_USER=`id -u` SERVER_GROUP=`id -u` \
WEB_USER=`id -u` WEB_GROUP=`id -u`
if [ -d root-tests ]
then
echo "Deleting old test environment..."
rm -rf root-tests
fi
echo "Installing test environment in root-tests/"
rm -rf root-tests && mkdir root-tests 2> /dev/null
make config-tests install \
GLASNOST=glasnost-tests PORT=8500 \
PREFIX=`pwd`/root-tests/usr/local \
VARPREFIX=`pwd`/root-tests/var/lib/ \
ETC_DIR=`pwd`/root-tests/etc/glasnost-tests \
LOGPREFIX=`pwd`/root-tests/var/log \
SERVER_USER=`id -u` SERVER_GROUP=`id -u` \
WEB_USER=`id -u` WEB_GROUP=`id -u` &> /dev/null
root-tests/usr/local/sbin/glasnost-tests-ctl start
(cd tmp-tests && ./launch.py $1)
root-tests/usr/local/sbin/glasnost-tests-ctl stop

View File

@ -46,10 +46,13 @@ __version__ = '$Revision$'[11:-2]
applicationName = 'glasnost-devel' # changed on make install
fileVersionNumber = '_'.join(['%04d' % int(number)
for number in __version__.split('.')])
versionNumber = '(unreleased cvs version)' # changed on make install
serverUser = 'glasnost' # changed on make install
import __builtin__
__builtin__.__dict__['N_'] = lambda x: x

View File

@ -58,11 +58,6 @@ ONE_WEEK = ONE_DAY * 7
ONE_MONTH = ONE_DAY * 28
ONE_YEAR = ONE_DAY * 365
MONTHS = ['', 'January', 'February', 'March', 'April', 'May', 'June', \
'July', 'August', 'September', 'October', 'November', 'December']
DAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', \
'Saturday', 'Sunday']
class AdminAppointmentsCommon(AdminCommon):
categoriesGroupId = None
categoriesGroupId_kind_balloonHelp = N_(

View File

@ -88,6 +88,7 @@ faultCodeUnknownAuthenticationMethod = 35
faultCodeUncountableGroup = 36
faultCodeNotAGroupUnion = 37
faultCodeIllegalRecursiveGroup = 38
faultCodeStringNotAvailableThroughGettext = 39
faultCodeUnknownVoteToken = 1000
faultCodeUnknownVoterToken = 1001
@ -417,6 +418,14 @@ class IllegalRecursiveGroup(BaseFault):
return 'Illegal recursive group %s' % groupId
class StringNotAvailableThroughGettext(BaseFault):
faultCode = faultCodeStringNotAvailableThroughGettext
def makeFaultString(self, string):
return 'String not available throught gettext: \'%s\'' % string
# Vote

View File

@ -2984,6 +2984,11 @@ class CreationTime(Time):
thingPublicName = N_('Creation Time')
def accepts(self, kind):
if isinstance(kind, Time):
return 1
return Time.accepts(self, kind)
def setAutomaticalValue(self, slot, init = 0):
if init:
slot.setValue(time.time())

View File

@ -516,6 +516,7 @@ class idUrl(rootUrl):
if id:
role = commonTools.extractRole(id)
localId = commonTools.extractLocalId(id)
self.id = id
else:
id = context.getVar('dispatcherId')
role = context.getVar('serverRole')
@ -532,6 +533,15 @@ class idUrl(rootUrl):
self.action = action
def getPath(self, **keywords):
try:
from glasnost.web.tools import getWebForServerRole
roleWeb = getWebForServerRole(self.role)
except ImportError:
roleWeb = None
if roleWeb and hasattr(roleWeb, 'idUrl') and (
not keywords or not keywords.has_key('ignoreWeb')):
return roleWeb.idUrl(self)
knownRoles = context.getVar('knownRoles')
if knownRoles and 'pagenames' in knownRoles:
from glasnost.proxy.tools import getProxyForServerRole

View File

@ -409,7 +409,8 @@ class ObjectServerMixin(things.ThingMixin):
# nothing.
# Happens for articles, books, uploadFiles... which
# should be converted to the new way of handling
print 'Not a directory: %s' % objectDirectoryPath
#print 'Not a directory: %s' % objectDirectoryPath
pass
things.ThingMixin.saveNonCore(
self, objectDirectoryPath, parentSlot = parentSlot)
@ -1005,6 +1006,7 @@ class Server(things.BaseThing, applications.Application):
if signalNumber == signal.SIGINT:
raise KeyboardInterrupt
if signalNumber == signal.SIGHUP:
print 'Received signal SIGHUP: reopening logs'
self.setLogFile()
return
if signalNumber == signal.SIGTERM:
@ -1044,7 +1046,7 @@ class Server(things.BaseThing, applications.Application):
if rcFile is not None:
fcntl.lockf(rcFile, fcntl.LOCK_SH)
version = self.readFileVersion(rcFile)
print 'file:', rcFile
#print 'file:', rcFile
data = glasnostPickle.load(rcFile)
fcntl.lockf(rcFile, fcntl.LOCK_UN)
rcFile.close()

View File

@ -46,6 +46,7 @@ __version__ = '$Revision$'[11:-2]
import os
import pwd
import sys
from glasnost.common.tools import *
@ -56,6 +57,20 @@ from glasnost.proxy.tools import getObject, getProxyForServerRole
def goDaemon(nochdir = 0, noclose = 0):
"""Run server as INIT daemon"""
if glasnost.serverUser.isdigit():
uid = int(glasnost.serverUser)
else:
try:
uid = pwd.getpwnam(glasnost.serverUser)[2]
except KeyError:
uid = os.getuid()
if uid != os.getuid():
try:
os.setuid(uid)
except OSError:
print 'WARNING: Failed to setuid() to %s' % uid
if os.fork():
os._exit(0)
os.setsid()

View File

@ -44,12 +44,14 @@ __doc__ = """Glasnost Appointments Web"""
__version__ = '$Revision$'[11:-2]
import calendar
import time
from glasnost.proxy.AppointmentsProxy import *
from ObjectsWeb import register, AdminMixin, ObjectWebMixin, ObjectsWebMixin
import calendaring
from tools import *
import time
import calendar
class AdminAppointments(AdminMixin, AdminAppointments):
categoriesGroupId_kind_widget_fieldLabel = N_('Categories Group')
@ -151,7 +153,7 @@ register(Appointment)
def weekNumberToDate(year, weekNumber):
jan4thSecs = time.mktime((year, 1, 4, 0, 0, 0, 0, 0, 0))
jan4thSecs = time.mktime((year, 1, 4, 0, 0, 0, 0, 0, time.localtime()[-1]))
secondsSinceJan4th = jan4thSecs + (weekNumber-1)*7*24*60*60
weekTuple = time.localtime(secondsSinceJan4th)
daysToAdd = - weekTuple[6]
@ -161,14 +163,14 @@ def weekNumberToDate(year, weekNumber):
def dateToWeekNumber(year, month, day):
janFirstSecs = time.mktime((year, 1, 1, 0, 0, 0, 0, 0, 0))
janFirstSecs = time.mktime((year, 1, 1, 0, 0, 0, 0, 0, time.localtime()[-1]))
janFirstTuple = time.localtime(janFirstSecs)
if janFirstTuple[6] < 4:
week0Secs = janFirstSecs - janFirstTuple[6]*24*60*60
else:
week0Secs = janFirstSecs + (7-janFirstTuple[6])*24*60*60
secondsSinceEpoch = time.mktime((year, month, day, 0, 0, 0, 0, 0, 0))
secondsSinceEpoch = time.mktime((year, month, day, 0, 0, 0, 0, 0, time.localtime()[-1]))
diffSecs = secondsSinceEpoch - week0Secs
weekNumber, mod = divmod(diffSecs, 7*24*60*60)
weekNumber = int(weekNumber) + 1
@ -181,30 +183,14 @@ def dateToWeekNumber(year, month, day):
class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
monthLabels = [N_('January'), N_('February'), N_('March'),
N_('April'), N_('May'), N_('June'),
N_('July'), N_('August'), N_('September'),
N_('October'), N_('November'), N_('December') ]
# Note to translators: those are "in sentence" labels, capitalized in
# English but not in (some) other languages
monthLabelsInSentence = [
N_('xJanuary'), N_('xFebruary'), N_('xMarch'),
N_('xApril'), N_('xMay'), N_('xJune'),
N_('xJuly'), N_('xAugust'), N_('xSeptember'),
N_('xOctober'), N_('xNovember'), N_('xDecember') ]
dayLabels = [ N_('Monday'), N_('Tuesday'), N_('Wednesday'), N_('Thursday'),
N_('Friday'), N_('Saturday'), N_('Sunday') ]
def agenda(self):
return ObjectsWebMixin.viewAll(self)
agenda.isPublicForWeb = 1
def day(self, year, month, day):
canAdd = self.canAddObject()
thisDay = time.mktime( [int(year), int(month), int(day)] + [0]*6 )
thisDay += time.timezone
thisDay = time.mktime( [int(year), int(month), int(day)] + [0]*5 +
[time.localtime()[-1]] )
appointments = self.getAppointments(thisDay, thisDay+86400).values()
dayAppointments = [x for x in appointments if x.start == thisDay]
@ -282,13 +268,13 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
def formatDate(self, dayTuple):
# TODO: grab user or site preference for date format (euro/us/...)
year, month, day = dayTuple[:3]
monthLabel = self.monthLabelsInSentence[month-1]
return '%d %s %d' % (day, _(monthLabel)[1:], year)
monthLabel = calendaring.getMonthLabelNoCapitalization(month)
return '%d %s %d' % (day, monthLabel, year)
def week(self, year, weekNumber):
canAdd = self.canAddObject()
today = list(time.gmtime(time.time())[:3])
today = list(time.localtime(time.time())[:3])
year, weekNumber = int(year), int(weekNumber)
@ -324,9 +310,9 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
tr += X.th()
for i in range(7):
thisDate = time.localtime(weekTime + i*24*60*60)
wd = _(self.dayLabels[i])
wd = _(calendaring.dayLabels[i])
dayLabel = '%s %d %s' % (wd, thisDate[2],
_(self.monthLabelsInSentence[thisDate[1]-1])[1:])
calendaring.getMonthLabelNoCapitalization(thisDate[1]))
tr += X.th(scope = 'col')(dayLabel)
table += X.thead(tr)
@ -338,7 +324,7 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
allDay = 0
for i in range(7):
thisDate = list(time.localtime(weekTime + i*24*60*60))
thisDateTime = time.mktime(thisDate)+time.timezone
thisDateTime = time.mktime(thisDate)
dayAppointments = [x for x in appointments \
if x.start == thisDateTime]
if len(dayAppointments) == 0:
@ -420,7 +406,7 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
week.isPublicForWeb = 1
def getSmallMonthLayout(self, year = 0, month = 0):
today = list(time.gmtime(time.time())[:3])
today = list(time.localtime(time.time())[:3])
if not year or not month:
year, month = today[:2]
@ -440,11 +426,11 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
caption = X.caption()
caption += X.a(href = X.actionUrl('month/%d/%d' % (
year, month)))('%s %s' % (_(self.monthLabels[month-1]), year))
year, month)))('%s %s' % (calendaring.getMonthLabel(month), year))
table += caption
tr = X.tr()
for wd in self.dayLabels:
for wd in calendaring.dayLabels:
tr += X.th(scope = 'col')(_(wd)[0])
table += X.thead(tr)
@ -466,9 +452,12 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
dayLabel = str(d)
thisDate = [year, month, d]
nextDate = [year, month, d+1]
timeStart = time.mktime(thisDate + [0]*5 +
[time.localtime()[-1]])
timeEnd = time.mktime(nextDate + [0]*5 +
[time.localtime()[-1]])
dayAppointments = [x for x in appointments if \
x.start >= time.mktime(thisDate + [0]*6) and \
x.start < time.mktime(nextDate + [0]*6)]
x.start >= timeStart and x.start < timeEnd]
className = ''
if thisDate == today:
className += 'today'
@ -504,7 +493,7 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
def month(self, year, month):
canAdd = self.canAddObject()
today = list(time.gmtime(time.time())[:3])
today = list(time.localtime(time.time())[:3])
year, month = int(year), int(month)
table = X.table(_class = 'calendar-month-full')
@ -523,14 +512,14 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
caption = X.caption()
caption += X.a(href = X.actionUrl('month/%d/%d' % (
prevYear, prevMonth)), _class = 'previous-month')('<<')
caption += X.span()('%s %s' % (_(self.monthLabels[month-1]), year))
caption += X.span()('%s %s' % (calendaring.getMonthLabel(month), year))
caption += X.a(href = X.actionUrl('month/%d/%d' % (
nextYear, nextMonth)), _class = 'next-month')('>>')
table += caption
tr = X.tr()
tr += X.th()
for wd in self.dayLabels:
for wd in calendaring.dayLabels:
tr += X.th(scope = 'col')(_(wd))
table += X.thead(tr)
@ -570,8 +559,10 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
dayContent = X.array()
dayContent += X.span(_class = 'day-title')(dayLabel)
thisDateTime = time.mktime(thisDate + [0]*6)+time.timezone
nextDateTime = time.mktime(nextDate + [0]*6)+time.timezone
thisDateTime = time.mktime(thisDate + [0]*5 +
[time.localtime()[-1]] )
nextDateTime = time.mktime(nextDate + [0]*5 +
[time.localtime()[-1]] )
dayAppointments = [x for x in appointments if \
(x.start >= thisDateTime and
x.start < nextDateTime )
@ -618,11 +609,12 @@ class AppointmentsWeb(ObjectsWebMixin, AppointmentsProxy):
layout += self.getLinksLayout(year = year, month = month,
exclude = ['month'])
return writePageLayout(layout, '%s %s' % (_(self.monthLabels[month-1]), year))
return writePageLayout(layout,
'%s %s' % (calendaring.getMonthLabel(month), year))
month.isPublicForWeb = 1
def getLinksLayout(self, year = None, month = None, day = None, exclude = None):
todayYear, todayMonth, todayDay = list(time.gmtime(time.time())[:3])
todayYear, todayMonth, todayDay = list(time.localtime(time.time())[:3])
thisYear = year or todayYear
thisMonth = month or todayMonth
thisDay = day or todayDay
@ -729,7 +721,7 @@ METHOD:PUBLISH
vcal.isPublicForWeb = ('GET', 'DELETE', 'PUT')
def viewAll(self):
year, month = time.gmtime(time.time())[:2]
year, month = time.localtime(time.time())[:2]
return self.month(year, month)
viewAll.isPublicForWeb = 1
@ -740,8 +732,8 @@ METHOD:PUBLISH
return pageNotFound()
ul = X.ul()
for i in range(12):
ul += X.li( X.a(href = X.actionUrl('month/%d/%d' % (
year, i+1))) ('%s %s' % (_(self.monthLabels[i]), year)))
ul += X.li( X.a(href = X.actionUrl('month/%d/%d' % (year, i+1))) (
'%s %s' % (calendaring.getMonthLabel(i+1), year)))
layout = X.array()
layout += ul
layout += self.getLinksLayout(year = year, exclude = ['year'])

View File

@ -44,9 +44,9 @@ __doc__ = """Glasnost TAL driver (used for included files)"""
__version__ = '$Revision$'[11:-2]
import marshal
import os
import os.path
import time
import glasnost.common.context as context
@ -54,8 +54,7 @@ import glasnost.common.context as context
compiledFiles = {}
def compilefile(file, mode=None):
assert mode in ("html", "xml", None)
t1 = time.time()
assert mode in ('html', 'xml', None)
templateDirectoryName = context.getVar('templateDirectoryName')
file = '%s/%s/%s' % (context.getVar('templatesDirectoryPath'), \
templateDirectoryName, file)
@ -65,9 +64,13 @@ def compilefile(file, mode=None):
if os.path.exists('%s/default/%s' % (fallbackPath, filename)):
file = '%s/default/%s' % (fallbackPath, filename)
language = context.getVar('readLanguages')[0]
precompiledFileName = '%sc.%s' % (file, language)
if os.path.exists(precompiledFileName) and \
os.stat(precompiledFileName)[8] >= os.stat(file)[8]:
return marshal.load(open(precompiledFileName))
cacheKey = file + '|' + language
if compiledFiles.has_key(cacheKey):
#open('/tmp/tal.cfile', 'a').write('%f (%s) (faster)\n' % (time.time()-t1, file))
return compiledFiles[cacheKey]
if mode is None:
ext = os.path.splitext(file)[1]
@ -85,6 +88,5 @@ def compilefile(file, mode=None):
p.parseFile(file)
code = p.getCode()
compiledFiles[cacheKey] = code
#open('/tmp/tal.cfile', 'a').write('%f (%s)\n' % (time.time()-t1, file))
return code

View File

@ -77,12 +77,12 @@ class GlasnostTALGenerator(TALGenerator.TALGenerator):
def getTranslation(self, text, sourceLanguage = 'en'):
virtualHost = context.getVar('virtualHost')
if sourceLanguage == 'en':
textT = _(text.strip())
if not textT == text.strip():
return textT
if sourceLanguage == context.getVar('readLanguages')[0]:
return text
if sourceLanguage == 'en' and _.im_self._catalog.has_key(text.strip()):
return _(text.strip())
translationsProxy = getProxyForServerRole('translations')
if translationsProxy and virtualHost.id:
if translationsProxy and virtualHost and virtualHost.id:
text, language, state = translationsProxy.getTranslationInfos(
text.strip(), # sourceString
virtualHost.id, # sourceId
@ -90,6 +90,9 @@ class GlasnostTALGenerator(TALGenerator.TALGenerator):
sourceLanguage, # sourceLanguage
context.getVar('readLanguages') # destinationLanguage
)
elif not virtualHost: # when precompiling templates
raise faults.StringNotAvailableThroughGettext(text)
return text
# I'd like those strings to be translated through gettext but they are from

View File

@ -176,6 +176,10 @@ register(UploadFile)
class UploadFilesWeb(ObjectsWebMixin, UploadFilesProxy):
def all(self):
return ObjectsWebMixin.viewAll(self)
all.isPublicForWeb = 1
def edit(self, id = '', again = '', error = '', **keywords):
if keywords is None:
keywords = {}

View File

@ -62,6 +62,20 @@ monthLabels = [N_('January'), N_('February'), N_('March'),
N_('July'), N_('August'), N_('September'),
N_('October'), N_('November'), N_('December') ]
# Note to translators: those are "in sentence" labels, capitalized in
# English but not in (some) other languages
monthLabelsNoCapitalization = [
N_('xJanuary'), N_('xFebruary'), N_('xMarch'),
N_('xApril'), N_('xMay'), N_('xJune'),
N_('xJuly'), N_('xAugust'), N_('xSeptember'),
N_('xOctober'), N_('xNovember'), N_('xDecember') ]
def getMonthLabel(monthNumber):
return _(monthLabels[monthNumber-1])
def getMonthLabelNoCapitalization(monthNumber):
return _(monthLabelsNoCapitalization[monthNumber-1])[1:]
def getMonthLayout(year, month, baseUrl, objects, startSlot, endSlot = None):
table = X.table(_class = 'calendar-month-full')
@ -74,11 +88,11 @@ def getMonthLayout(year, month, baseUrl, objects, startSlot, endSlot = None):
caption = X.caption()
caption += X.a(
href = '%s/%d/%d' % (baseUrl.getAsUrl(), prevYear, prevMonth),
href = '%s/%d/%d' % (baseUrl, prevYear, prevMonth),
_class = 'previous-month')('<<')
caption += X.span()('%s %s' % (_(monthLabels[month-1]), year))
caption += X.a(
href = '%s/%d/%d' % (baseUrl.getAsUrl(), nextYear, nextMonth),
href = '%s/%d/%d' % (baseUrl, nextYear, nextMonth),
_class = 'next-month')('>>')
table += caption
@ -92,7 +106,7 @@ def getMonthLayout(year, month, baseUrl, objects, startSlot, endSlot = None):
if not endSlot:
endSlot = startSlot
today = list(time.gmtime(time.time())[:3])
today = list(time.localtime(time.time())[:3])
tbody = X.tbody()
table += tbody
@ -112,11 +126,13 @@ def getMonthLayout(year, month, baseUrl, objects, startSlot, endSlot = None):
nextDate = [year, month, d+1]
dayContent = X.array()
dayContent += X.span(_class = 'day-title')(dayLabel)
timeStart = time.mktime(thisDate + [0]*5 + [time.localtime()[-1]])
timeEnd = time.mktime(nextDate + [0]*5 + [time.localtime()[-1]])
dayObjects = [x for x in objects if \
getattr(x, startSlot) < time.mktime(nextDate + [0]*6) and \
getattr(x, startSlot) < timeEnd and \
((getattr(x, endSlot) is None and
getattr(x, startSlot) >= time.mktime(thisDate + [0]*6) ) or \
getattr(x, endSlot) >= time.mktime(thisDate + [0]*6))]
getattr(x, startSlot) >= timeStart ) or \
getattr(x, endSlot) >= timeStart)]
dayObjects.sort(lambda x,y: cmp(getattr(x, startSlot), getattr(y, startSlot)))
if len(dayObjects):
ul = X.ul()

View File

@ -62,6 +62,8 @@ import glasnost.proxy.widgets as proxyWidgets
import properties
import things
import calendaring
from tools import *
import translation
@ -420,20 +422,6 @@ register(Amount)
class Date(TimeMixin, proxyWidgets.Date):
sep = '-'
monthTitles = {
'01':N_('xJanuary'),
'02':N_('xFebruary'),
'03':N_('xMarch'),
'04':N_('xApril'),
'05':N_('xMay'),
'06':N_('xJune'),
'07':N_('xJuly'),
'08':N_('xAugust'),
'09':N_('xSeptember'),
'10':N_('xOctober'),
'11':N_('xNovember'),
'12':N_('xDecember')}
monthLabels = monthTitles
def getHtmlViewValue(self, slot, fields, **keywords):
yearFieldValue = slot.getFieldOption(fields, 'year', default = '')
@ -443,7 +431,8 @@ class Date(TimeMixin, proxyWidgets.Date):
partsToDisplay = slot.getKind().requiredParts
layout = X.array()
if monthFieldValue:
monthTitle = self.monthTitles[monthFieldValue]
monthTitle = calendaring.getMonthLabelNoCapitalization(
int(monthFieldValue))
else:
monthTitle = ''
@ -506,7 +495,8 @@ class Date(TimeMixin, proxyWidgets.Date):
optionAttributes['selected'] = 'selected'
monthSelect += X.option(
value = value, **optionAttributes)(
_(self.monthLabels[value])[1:])
calendaring.getMonthLabelNoCapitalization(
int(value)))
layout += monthSelect
layout += X.nbsp
# day

View File

@ -69,3 +69,7 @@ ANY WARRANTY**; without even the implied warranty of **MERCHANTABILITY** or
**FITNESS FOR A PARTICULAR PURPOSE**. See the `GNU General Public License
<alias gpl>`_ for more details.
----
`Download Glasnost <http://glasnost.entrouvert.org/downloading>`_

View File

@ -70,3 +70,7 @@ GARANTIE ; sans m
MARCHANDE ou de CONVENIR À UN BESOIN PARTICULIER. Pour plus de détails, lisez
la `Licence Publique Générale GNU <alias gpl>`_.
----
`Télécharger Glasnost <http://glasnost.entrouvert.org/downloading>`_

View File

@ -70,6 +70,7 @@ class Application(applications.Application):
def askUserEmailAddress(self):
defaultEmailAddress = '%s@localhost' % os.getenv('USER')
return defaultEmailAddress
while 1:
try:
emailAddress = raw_input(

View File

@ -37,7 +37,7 @@
<div id="tux">
<form id="searchForm" tal:attributes="action roleUrl('search', 'go')">
<label for="search" accesskey="4" tal:translate="fr">Recherche:</label><br />
<label for="search" accesskey="4" tal:translate="">Search</label><br />
<input id="search" name="terms" size="10"/> <input type="submit" class="button" value="OK"/>
</form>

View File

@ -102,7 +102,7 @@
<td width="55%">
<p tal:condition="user"><font face="tahoma,verdana,arial,helvetica,sans-serif" size="1">
<span tal:trasnalte="">User:</span> <span tal:replace="user"></span>
<span tal:translate="">User:</span> <span tal:replace="user"></span>
</font>
</p>

View File

@ -17,7 +17,7 @@
<body id="libre-entreprise-com">
<div id="header">
<h1><a href="/" tal:reroot="href" tal:translate="fr">Réseau Libre-entreprise</a></h1>
<h1><a href="/" tal:reroot="href" tal:content="str(virtualHost)">Réseau Libre-entreprise</a></h1>
</div>
<div id="glasnost-forms" tal:condition="0">

View File

@ -33,7 +33,7 @@
</div>
<form id="searchForm" tal:attributes="action roleUrl('search', 'go')">
<label for="search" accesskey="4" tal:translate="fr">Recherche:</label><br />
<label for="search" accesskey="4" tal:translate="">Search</label><br />
<input id="search" name="terms" size="10"/> <input type="submit" class="button" value="OK"/>
</form>

View File

@ -101,99 +101,14 @@ class Application(applications.Application):
def main(self):
self.launch()
print """\
Welcome to the Glasnost unit tests
==================================
Note: using Python %s
Phase 0: Setup tests accounts and informations.
-----------------------------------------------
""" % sys.version[:6]
# Glasnost admin
validEmail = 0
helpstring = """
Need help ?
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
The mail address is used by glasnost to send passwords.
So it must be valid. You can easely write the same email address for the test
administrator and for the test user.
But, the email addresses must not be the same, so note that you have to
differenciate them by capitalize letters, or different host name.
i.e: me@localhost and me@LOCALHOST, or me@localhost and me@hostname.
"""
defaultEmail = '%s@localhost' % getenv('USER')
while not validEmail:
administratorEmail = raw_input("""
Please enter a local user email address for the glasnost admin
(or write \'help\' to get help)
Glasnost Admin e-mail address (default: %s): """ % defaultEmail)
if administratorEmail == '':
administratorEmail = defaultEmail
if match(r'^\w[\w,.]*@\w[\w,.]*$',administratorEmail):
validEmail = 1
else:
print helpstring
validEmail = 0
defaultEmail = '%s@LOCALHOST' % getenv('USER')
while not validEmail:
userEmail = raw_input("""
Please enter a local user email address for a standard test user
(or write \'help\' to get help)
Glasnost test user e-mail address (default: %s): """ % defaultEmail)
if userEmail == '':
userEmail = defaultEmail
if match(r'^\w[\w,.]*@\w[\w,.]*$',userEmail) \
and not userEmail == administratorEmail:
validEmail = 1
else:
print helpstring
administratorEmail = '%s@localhost' % getenv('USER')
userEmail = '%s@LOCALHOST' % getenv('USER')
#
# Test of test automated functions
#
# Email reading.
print 'Can I read Admin mail ?'
try:
if canReadMailboxFirstMessage(administratorEmail.split('@')[0]):
print ' Yes !\n'
else:
print ' No... :-('
print '\n I give up !\n'
sys.exit(1)
except:
pass
print 'Can I read test user mail ?'
try:
if canReadMailboxFirstMessage(userEmail.split('@')[0]):
print ' Yes !\n'
else:
print ' No... :-('
print '\n I give up !\n'
sys.exit(1)
except:
pass
raw_input('Press ENTER to launch the tests...')
print """
===============================================================================
=============================LAUNCHING TESTS===================================
===============================================================================
"""
print "Running tests..."
virtualHostName = context.getVar('dispatcherHostName')
TestCase.VirtualHostsTestCase.virtualHostName = virtualHostName
@ -238,7 +153,7 @@ Glasnost test user e-mail address (default: %s): """ % defaultEmail)
else:
levelString = '%s.%d' % (level, iteration)
helpString = '%s: %s \n' % (levelString, suites.__doc__)
helpString = '\n%s: %s \n' % (levelString, suites.__doc__)
print helpString
if isinstance(suites, definitions.TestSuitesSequence):
self.unroll(suites, levelString)