예제 #1
0
    def writeBody(self):
        curTime = time()
        self.writeln('''
        <table style="margin-left:auto;margin-right:auto">
            <tr><th>Version:</th><td>%s</td></tr>
            <tr><th>Local time:</th><td>%s</td></tr>
            <tr><th>Global time:</th><td>%s</td></tr>
        </table>''' % (self._wrapper.version(), asctime(
            localtime(curTime)), asctime(gmtime(curTime))))
        self.startMenu()
        self.menuItem(
            'Script log contents', '_dumpCSV?filename=%s' %
            urlEncode(self._wrapper.setting('ScriptLogFilename')))
        self.menuItem(
            'Error log contents', '_dumpErrors?filename=%s' %
            urlEncode(self._wrapper.setting('ErrorLogFilename')))
        self.menuItem('Show config', '_showConfig')
        self.endMenu()

        self.writeln('''
<!--
begin-parse
{
'Version': %r,
'LocalTime': %r,
'GlobalTime': %r
}
end-parse
-->''' % (self._wrapper.version(), localtime(curTime), gmtime(curTime)))
예제 #2
0
    def writeBody(self):
        curTime = time()
        self.writeln('''
        <table align="center" cellspacing="2" cellpadding="2" border="0">
            <tr><th>Version:</th><td>%s</td></tr>
            <tr><th>Local time:</th><td>%s</td></tr>
            <tr><th>Global time:</th><td>%s</td></tr>
        </table>''' % (self._wrapper.version(),
        asctime(localtime(curTime)), asctime(gmtime(curTime))))
        self.startMenu()
        self.menuItem('Script log contents', '_dumpCSV?filename=%s'
            % urlEncode(self._wrapper.setting('ScriptLogFilename')))
        self.menuItem('Error log contents', '_dumpErrors?filename=%s'
            % urlEncode(self._wrapper.setting('ErrorLogFilename')))
        self.menuItem('Show config', '_showConfig')
        self.endMenu()

        self.writeln('''
<!--
begin-parse
{
'Version': %r,
'LocalTime': %r,
'GlobalTime': %r
}
end-parse
-->''' % (self._wrapper.version(), localtime(curTime), gmtime(curTime)))
예제 #3
0
파일: Errors.py 프로젝트: Cito/w4py
    def cellContents(self, rowIndex, colIndex, value):
        """Hook for subclasses to customize the contents of a cell.

        Based on any criteria (including location).
        """
        if self._headings[colIndex] in ('pathname', 'error report filename'):
            path = self.application().serverSidePath()
            if value.startswith(path):
                value = value[len(path):]
                if value.startswith(sep):
                    value = value[len(sep):]
                link = 'View?filename=%s' % urlEncode(value)
                value = value.replace(sep, sep + '<wbr>')
                value = '<a href="%s">%s</a>' % (link, value)
            else:
                value = value.replace(sep, sep + '<wbr>')
            return value
        elif self._headings[colIndex] == 'time':
            return '<span style="white-space:nowrap">%s</span>' % (value)
        else:
            return self.htmlEncode(value)
예제 #4
0
    def cellContents(self, rowIndex, colIndex, value):
        """Hook for subclasses to customize the contents of a cell.

        Based on any criteria (including location).
        """
        if self._headings[colIndex] in ('pathname', 'error report filename'):
            path = self.application().serverSidePath()
            if value.startswith(path):
                value = value[len(path):]
                if value.startswith(sep):
                    value = value[len(sep):]
                link = 'View?filename=%s' % urlEncode(value)
                value = value.replace(sep, sep + '<wbr>')
                value = '<a href="%s">%s</a>' % (link, value)
            else:
                value = value.replace(sep, sep + '<wbr>')
            return value
        elif self._headings[colIndex] == 'time':
            return '<span style="white-space:nowrap">%s</span>' % (value)
        else:
            return self.htmlEncode(value)
예제 #5
0
  def writeContent(self, trans=None):
    #
    # this servlet creates Expenses data
    #

    page = self.transaction.request().field('page','Main')
    #
    # create Expenses object
    #
    globalSetVars = self._globalSetVars
    store = globalSetVars['store']
    ExpensesNr=self.transaction.request().field('Nr','')
    Expenses = AccountsAK()
    #
    # change Expenses object
    #
    for attr in ExpensesAttrs:
      if attr not in standardAttrs:
        if ExpensesFields[attr][ExpensesType] == 'string':
          print self.transaction.request().field(attr,'')
          Expenses.setValueForKey(attr, self.transaction.request().field(attr,''))
        elif ExpensesFields[attr][ExpensesType] == 'float':
          Expenses.setValueForKey(attr, float(string.replace(self.transaction.request().field(attr,'0,0'),',','.')))
        elif (ExpensesFields[attr][ExpensesType] == 'datetime') and self.request.field(attr,''):
          Expenses.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
        elif (ExpensesFields[attr][ExpensesType] == 'date') and self.transaction.request().field(attr,''):
          Expenses.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
    #
    # set standard attributes
    #
    Expenses.setID('AK'+ExpensesNr)
    Expenses.setErsteingabeAm(DateTime.now())
    Expenses.setChangedBy(self.transaction.session().value('authenticated_user',''))
    Expenses.setChangedAt(DateTime.now())
    Expenses.setChangedOn(self.getSite())
    #
    # store Expenses in database
    #
    store.addObject(Expenses)
    try:
      store.saveChanges()
      #
      # back to Expenses page
      #
      self.transaction.response().sendRedirect('ExpensesView?index=' + ExpensesNr)
    except OperationalError,x:
      store.discardEverything()
      errorCode,errorText = x
      #
      # back to error page
      #
      self.transaction.response().sendRedirect('Error?problem=Daten+konnten+nicht+gespeichert+werden!&reason=' + urlEncode(str(errorText)))
예제 #6
0
  def writeContent(self, trans=None):
    #
    # this servlet creates Member data
    #

    account = self.transaction.request().field('account','')
    page = self.transaction.request().field('page','Main')
    #
    # create member object
    #
    globalSetVars = self._globalSetVars
    store = globalSetVars['store']
    if self.transaction.request().field('MitgliedsNr',None)[-1:] == "0":
      storeObjects = store.fetchObjectsOfClass('IDs','WHERE %s = "%s"' % ('Tablename',self.storeName))
      if (len(storeObjects) == 1) and self.transaction.request().field('ID',None):
        id = storeObjects[0]
        id.setLastID(int(self.transaction.request().field('MitgliedsNr',None)))
    member = AccountsMI()
    #
    # change member object
    #
    for attr in memberAttrs:
      if attr not in standardAttrs:
        if memberFields[attr][memberType] == 'string':
          print self.transaction.request().field(attr,'')
          member.setValueForKey(attr, self.transaction.request().field(attr,''))
        elif memberFields[attr][memberType] == 'float':
          member.setValueForKey(attr, float(string.replace(self.transaction.request().field(attr,'0,0'),',','.')))
        elif (memberFields[attr][memberType] == 'datetime') and self.request.field(attr,''):
          member.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
        elif (memberFields[attr][memberType] == 'date') and self.transaction.request().field(attr,''):
          member.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
    #
    # set fee dates
    #
    member.setValueForKey('BeitragsartAb1', DateTime.DateTimeFrom(self.transaction.request().field('Eintrittsdatum','')))
    member.setValueForKey('BeitragsartFreiAb1', None)
    member.setValueForKey('BeitragsartErhebungAb1', DateTime.DateTimeFrom(self.transaction.request().field('Eintrittsdatum','')))
    #
    # set standard attributes
    #
    member.setErsteingabeAm(DateTime.now())
    member.setChangedBy(self.transaction.session().value('authenticated_user',''))
    member.setChangedAt(DateTime.now())
    member.setChangedOn(self.getSite())
    #
    # store member in database
    #
    store.addObject(member)
    try:
      store.saveChanges()
      #
      # back to member page
      #
      self.transaction.response().sendRedirect('MemberView?index=' + account[2:])
    except OperationalError,x:
      store.discardEverything()
      errorCode,errorText = x
      #
      # back to error page
      #
      self.transaction.response().sendRedirect('Error?problem=Daten+konnten+nicht+gespeichert+werden!&reason=' + urlEncode(str(errorText)))
예제 #7
0
  def writeContent(self, trans=None):
    #
    # this servlet creates Member data
    #

    account = self.transaction.request().field('account','')
    page = self.transaction.request().field('page','Main')
    #
    # create personal object
    #
    globalSetVars = self._globalSetVars
    store = globalSetVars['store']
    personal = AccountsTR()
    #
    # change personal object
    #
    for attr in personalAttrs:
      if attr not in standardAttrs:
        if personalFields[attr][personalType] == 'string':
          print self.transaction.request().field(attr,'')
          personal.setValueForKey(attr, self.transaction.request().field(attr,''))
        elif personalFields[attr][personalType] == 'float':
          if string.strip(self.transaction.request().field(attr,'')):
            personal.setValueForKey(attr, float(string.replace(self.transaction.request().field(attr,'0,00'),',','.')))
          else:
            personal.setValueForKey(attr, None)
        elif (personalFields[attr][personalType] == 'datetime') and self.request.field(attr,''):
          personal.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
        elif (personalFields[attr][personalType] == 'date') and self.transaction.request().field(attr,''):
          personal.setValueForKey(attr, DateTime.DateTimeFrom(self.transaction.request().field(attr,'')))
    #
    # set standard attributes
    #
    personal.setErsteingabeAm(DateTime.now())
    personal.setChangedBy(self.transaction.session().value('authenticated_user',''))
    personal.setChangedAt(DateTime.now())
    personal.setChangedOn(self.getSite())
    #
    # store personal in database
    #
    store.addObject(personal)
    try:
      store.saveChanges()
    except OperationalError,x:
      store.discardEverything()
      errorCode,errorText = x
      #
      # back to error page
      #
      self.transaction.response().sendRedirect('Error?problem=Daten+konnten+nicht+gespeichert+werden!&reason=' + urlEncode(str(errorText)))
예제 #8
0
    def urlEncode(s):
        """Quotes special characters using the % substitutions.

        This method does the same as the `urllib.quote_plus()` function.
        """
        return urlEncode(s)