• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python datefmt.to_utimestamp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trac.util.datefmt.to_utimestamp函数的典型用法代码示例。如果您正苦于以下问题:Python to_utimestamp函数的具体用法?Python to_utimestamp怎么用?Python to_utimestamp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了to_utimestamp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: modify_comment

    def modify_comment(self, cdate, author, comment, when=None):
        """Modify a ticket comment specified by its date, while keeping a
        history of edits.
        """
        ts = to_utimestamp(cdate)
        if when is None:
            when = datetime.now(utc)
        when_ts = to_utimestamp(when)

        @self.env.with_transaction()
        def do_modify(db):
            cursor = db.cursor()
            # Find the current value of the comment
            cursor.execute("""
                SELECT newvalue FROM ticket_change 
                WHERE ticket=%s AND time=%s AND field='comment'
                """, (self.id, ts))
            old_comment = False
            for old_comment, in cursor:
                break
            if comment == (old_comment or ''):
                return

            # Comment history is stored in fields named "_comment%d"
            # Find the next edit number
            cursor.execute("""
                SELECT field FROM ticket_change 
                WHERE ticket=%%s AND time=%%s AND field %s
                """ % db.like(), (self.id, ts,
                                  db.like_escape('_comment') + '%'))
            fields = list(cursor)
            rev = fields and max(int(field[8:]) for field, in fields) + 1 or 0
            cursor.execute("""
                INSERT INTO ticket_change
                    (ticket,time,author,field,oldvalue,newvalue) 
                VALUES (%s,%s,%s,%s,%s,%s)
                """, (self.id, ts, author, '_comment%d' % rev,
                      old_comment or '', str(when_ts)))
            if old_comment is False:
                # There was no comment field, add one, find the original author
                # in one of the other changed fields
                cursor.execute("""
                    SELECT author FROM ticket_change 
                    WHERE ticket=%%s AND time=%%s AND NOT field %s
                    LIMIT 1
                    """ % db.like(), (self.id, ts, db.like_escape('_') + '%'))
                old_author = None
                for old_author, in cursor:
                    break
                cursor.execute("""
                    INSERT INTO ticket_change 
                        (ticket,time,author,field,oldvalue,newvalue) 
                    VALUES (%s,%s,%s,'comment','',%s)
                    """, (self.id, ts, old_author, comment))
            else:
                cursor.execute("""
                    UPDATE ticket_change SET newvalue=%s 
                    WHERE ticket=%s AND time=%s AND 
                    field='comment'
                    """, (comment, self.id, ts))
开发者ID:zjj,项目名称:trac_hack,代码行数:60,代码来源:model.py


示例2: query

    def query(env, status=None, threshold=None):
        ret = []
        where_clause = ''
        if status is not None:
            if status == 'active':
                where_clause = ' WHERE status<>\'closed\''
            elif status == 'closed':
                where_clause = ' WHERE status=\'closed\''
            elif status == 'new':
                where_clause = ' WHERE status=\'new\''
            else:
                where_clause = ' WHERE status=\'%s\'' % status

        if threshold is not None:
            (threshold_column, threshold_time) = threshold
            if where_clause:
                where_clause += ' AND %s < %i' % (threshold_column, to_utimestamp(threshold_time))
            else:
                where_clause = ' WHERE %s < %i' % (threshold_column, to_utimestamp(threshold_time))

        fields = CrashDumpSystem(env).get_crash_fields()
        std_fields = []
        for f in fields:
            if f.get('custom'):
                pass
            else:
                std_fields.append(f['name'])

        # Fetch the standard crashdump fields
        for row in env.db_query("SELECT id,%s FROM crashdump %s" % (','.join(std_fields), where_clause)):
            crash = CrashDump(env=env, must_exist=True, row=row)
            ret.append(crash)
        return ret
开发者ID:aroth-arsoft,项目名称:trac-crashdump,代码行数:33,代码来源:model.py


示例3: ticket_activity

def ticket_activity(project_id, start_date, end_date, db, req):
    """
    Get query response for specified time interval:
    Data: <ticket status>: <count tickets>
    """
    sql_expr = """
    SELECT t.status, COUNT(t.id)
    FROM ticket t
    WHERE t.project_id=%s AND t.changetime >= %s AND t.changetime < %s
    GROUP BY t.status;
    """

    cursor = db.cursor()
    cursor.execute(sql_expr, (project_id,
                              to_utimestamp(start_date), to_utimestamp(end_date))
                   )
    results = [(r[0], r[1]) for r in cursor]

    query_response = QueryResponse("ticket_activity", req.href('/chrome'))
    query_response.set_title(_("Ticket activity"))
    query_response.set_columns((_('ticket status'), _('tickets')))
    query_response.set_results(results)
    chart = query_response.chart_info
    chart.type = "Pie"
    chart.width = 480
    chart.height = 300
    chart.tool_tip = "%s:#x_label#<br>%s:#val#" % (_('status'), _('tickets'))
    chart.line_color = "#000000"
    chart.x_labels = [row[0] for row in results]
    chart.data = [row[1] for row in results]

    return query_response
开发者ID:lexqt,项目名称:EduTracMetrix,代码行数:32,代码来源:reports.py


示例4: test_initial_sync

    def test_initial_sync(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)],
                               youngest_rev=1)
        changes = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                   ('trunk/README', Node.FILE, Changeset.ADD, None, None)]
        changesets = [Mock(Changeset, repos, 0, '', '', t1,
                           get_changes=lambda: []),
                      Mock(Changeset, repos, 1, 'Import', 'joe', t2,
                           get_changes=lambda: iter(changes))]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync()

        cursor = self.db.cursor()
        cursor.execute("SELECT rev,time,author,message FROM revision")
        self.assertEquals(('0', to_utimestamp(t1), '', ''),
                          cursor.fetchone())
        self.assertEquals(('1', to_utimestamp(t2), 'joe', 'Import'),
                          cursor.fetchone())
        self.assertEquals(None, cursor.fetchone())
        cursor.execute("""
            SELECT rev,path,node_type,change_type,base_path,base_rev
            FROM node_change
            """)
        self.assertEquals(('1', 'trunk', 'D', 'A', None, None),
                          cursor.fetchone())
        self.assertEquals(('1', 'trunk/README', 'F', 'A', None, None),
                          cursor.fetchone())
        self.assertEquals(None, cursor.fetchone())
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:30,代码来源:cache.py


示例5: test_update_sync

    def test_update_sync(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        t3 = datetime(2003, 1, 1, 1, 1, 1, 0, utc)
        self.preset_cache(
            (('0', to_utimestamp(t1), '', ''), []),
            (('1', to_utimestamp(t2), 'joe', 'Import'),
             [('trunk', 'D', 'A', None, None),
              ('trunk/README', 'F', 'A', None, None)]),
            )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)],
                               youngest_rev=2)
        changes = [('trunk/README', Node.FILE, Changeset.EDIT, 'trunk/README',
                    1)]
        changesets = [
            None,
            Mock(Changeset, repos, 1, '', '', t2, get_changes=lambda: []),
            Mock(Changeset, repos, 2, 'Update', 'joe', t3,
                 get_changes=lambda: iter(changes))
            ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync()

        with self.env.db_query as db:
            self.assertEquals([(to_utimestamp(t3), 'joe', 'Update')],
                db("SELECT time, author, message FROM revision WHERE rev='2'"))
            self.assertEquals([('trunk/README', 'F', 'E', 'trunk/README',
                                '1')],
                    db("""SELECT path, node_type, change_type, base_path,
                                 base_rev
                          FROM node_change WHERE rev='2'"""))
开发者ID:thimalk,项目名称:bloodhound,代码行数:31,代码来源:cache.py


示例6: test_sync_changeset

    def test_sync_changeset(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        self.preset_cache(
            (("0", to_utimestamp(t1), "", ""), []),
            (
                ("1", to_utimestamp(t2), "joe", "Import"),
                [("trunk", "D", "A", None, None), ("trunk/README", "F", "A", None, None)],
            ),
        )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)], youngest_rev=1)
        changes1 = [
            ("trunk", Node.DIRECTORY, Changeset.ADD, None, None),
            ("trunk/README", Node.FILE, Changeset.ADD, None, None),
        ]
        changesets = [
            Mock(Changeset, repos, 0, "**empty**", "joe", t1, get_changes=lambda: []),
            Mock(Changeset, repos, 1, "Initial Import", "joe", t2, get_changes=lambda: iter(changes1)),
        ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync_changeset(0)

        rows = self.env.db_query("SELECT time, author, message FROM revision ORDER BY rev")
        self.assertEquals(2, len(rows))
        self.assertEquals((to_utimestamp(t1), "joe", "**empty**"), rows[0])
        self.assertEquals((to_utimestamp(t2), "joe", "Import"), rows[1])
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:26,代码来源:cache.py


示例7: test_update_sync

    def test_update_sync(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        t3 = datetime(2003, 1, 1, 1, 1, 1, 0, utc)
        self.preset_cache(
            (("0", to_utimestamp(t1), "", ""), []),
            (
                ("1", to_utimestamp(t2), "joe", "Import"),
                [("trunk", "D", "A", None, None), ("trunk/README", "F", "A", None, None)],
            ),
        )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)], youngest_rev=2)
        changes = [("trunk/README", Node.FILE, Changeset.EDIT, "trunk/README", 1)]
        changesets = [
            None,
            Mock(Changeset, repos, 1, "", "", t2, get_changes=lambda: []),
            Mock(Changeset, repos, 2, "Update", "joe", t3, get_changes=lambda: iter(changes)),
        ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync()

        with self.env.db_query as db:
            self.assertEquals(
                [(to_utimestamp(t3), "joe", "Update")], db("SELECT time, author, message FROM revision WHERE rev='2'")
            )
            self.assertEquals(
                [("trunk/README", "F", "E", "trunk/README", "1")],
                db(
                    """SELECT path, node_type, change_type, base_path,
                                 base_rev
                          FROM node_change WHERE rev='2'"""
                ),
            )
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:33,代码来源:cache.py


示例8: modify_comment

    def modify_comment(self, cdate, author, comment, when=None):
        """Modify a ticket comment specified by its date, while keeping a
        history of edits.
        """
        ts = to_utimestamp(cdate)
        if when is None:
            when = datetime.now(utc)
        when_ts = to_utimestamp(when)

        with self.env.db_transaction as db:
            # Find the current value of the comment
            old_comment = False
            for old_comment, in db("""
                    SELECT newvalue FROM ticket_change
                    WHERE ticket=%s AND time=%s AND field='comment'
                    """, (self.id, ts)):
                break
            if comment == (old_comment or ''):
                return

            # Comment history is stored in fields named "_comment%d"
            # Find the next edit number
            fields = db("""SELECT field FROM ticket_change
                           WHERE ticket=%%s AND time=%%s AND field %s
                           """ % db.prefix_match(),
                           (self.id, ts, db.prefix_match_value('_comment')))
            rev = max(int(field[8:]) for field, in fields) + 1 if fields else 0
            db("""INSERT INTO ticket_change
                    (ticket,time,author,field,oldvalue,newvalue)
                  VALUES (%s,%s,%s,%s,%s,%s)
                  """, (self.id, ts, author, '_comment%d' % rev,
                        old_comment or '', str(when_ts)))
            if old_comment is False:
                # There was no comment field, add one, find the
                # original author in one of the other changed fields
                for old_author, in db("""
                        SELECT author FROM ticket_change
                        WHERE ticket=%%s AND time=%%s AND NOT field %s LIMIT 1
                        """ % db.prefix_match(),
                        (self.id, ts, db.prefix_match_value('_'))):
                    db("""INSERT INTO ticket_change
                            (ticket,time,author,field,oldvalue,newvalue)
                          VALUES (%s,%s,%s,'comment','',%s)
                          """, (self.id, ts, old_author, comment))
            else:
                db("""UPDATE ticket_change SET newvalue=%s
                      WHERE ticket=%s AND time=%s AND field='comment'
                      """, (comment, self.id, ts))

            # Update last changed time
            db("UPDATE ticket SET changetime=%s WHERE id=%s",
               (when_ts, self.id))

        self.values['changetime'] = when

        old_comment = old_comment or ''
        for listener in TicketSystem(self.env).change_listeners:
            if hasattr(listener, 'ticket_comment_modified'):
                listener.ticket_comment_modified(self, cdate, author, comment,
                                                 old_comment)
开发者ID:pkdevbox,项目名称:trac,代码行数:60,代码来源:model.py


示例9: test_sync_changeset

    def test_sync_changeset(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        self.preset_cache(
            (('0', to_utimestamp(t1), '', ''), []),
            (('1', to_utimestamp(t2), 'joe', 'Import'),
             [('trunk', 'D', 'A', None, None),
              ('trunk/README', 'F', 'A', None, None)]),
            )
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)],
                               youngest_rev=1)
        changes1 = [('trunk', Node.DIRECTORY, Changeset.ADD, None, None),
                    ('trunk/README', Node.FILE, Changeset.ADD, None, None)]
        changesets = [
            Mock(Changeset, repos, 0, '**empty**', 'joe', t1,
                 get_changes=lambda: []),
            Mock(Changeset, repos, 1, 'Initial Import', 'joe', t2,
                 get_changes=lambda: iter(changes1)),
            ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync_changeset(0)

        cursor = self.db.cursor()
        cursor.execute("SELECT time,author,message FROM revision ORDER BY rev")
        self.assertEquals((to_utimestamp(t1), 'joe', '**empty**'),
                          cursor.fetchone())
        self.assertEquals((to_utimestamp(t2), 'joe', 'Import'),
                          cursor.fetchone())
        self.assertEquals(None, cursor.fetchone())
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:29,代码来源:cache.py


示例10: test_missing_comment_edit

    def test_missing_comment_edit(self):
        """Modify a comment where one edit is missing"""
        ticket = Ticket(self.env, self.id)
        t1 = self.created + timedelta(seconds=70)
        ticket.modify_comment(self._find_change(ticket, 1), "joe", "New comment 1", t1)
        t2 = self.created + timedelta(seconds=80)
        ticket.modify_comment(self._find_change(ticket, 1), "joe", "Other comment 1", t2)

        self.assertChange(
            ticket,
            1,
            self.t1,
            "jack",
            comment=dict(author="jack", old="1", new="Other comment 1"),
            _comment0=dict(author="joe", old="Comment 1", new=str(to_utimestamp(t1))),
            _comment1=dict(author="joe", old="New comment 1", new=str(to_utimestamp(t2))),
        )

        cursor = self.db.cursor()
        cursor.execute("DELETE FROM ticket_change " "WHERE field='_comment0'")
        self.db.commit()

        t3 = self.created + timedelta(seconds=90)
        ticket.modify_comment(self._find_change(ticket, 1), "joe", "Newest comment 1", t3)

        self.assertChange(
            ticket,
            1,
            self.t1,
            "jack",
            comment=dict(author="jack", old="1", new="Newest comment 1"),
            _comment1=dict(author="joe", old="New comment 1", new=str(to_utimestamp(t2))),
            _comment2=dict(author="joe", old="Other comment 1", new=str(to_utimestamp(t3))),
        )
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:34,代码来源:model.py


示例11: set_date_range

    def set_date_range(self, start_date, stop_date):

        db = self.env.get_read_db()
        cursor = db.cursor()

        cursor.execute('''
            SELECT rev, time, author
            FROM revision
            WHERE repos IN (
                SELECT id FROM repository
                WHERE name='project_id' AND value=%s
            ) AND time >= %s AND time < %s
            ORDER BY time
            ''', (str(self.pid), to_utimestamp(start_date), to_utimestamp(stop_date)))

        self.changesets = []
        for rev, time, author in cursor:
            self.changesets.append((rev,time,author))

        self.start_date = start_date
        self.stop_date = stop_date
        if not self.changesets:
            self.first_rev = self.last_rev = 0
        else:
            self.first_rev = self.changesets[0][0]
            self.last_rev = self.changesets[-1][0]
开发者ID:lexqt,项目名称:EduTracMetrix,代码行数:26,代码来源:model.py


示例12: _process_add

    def _process_add(self, req, ticket):
        if req.method == "POST" and self._validate_add(req):
            if req.args.get('reminder_type') == 'interval':
                time = clear_time(to_datetime(None))
                delta = _time_intervals[req.args.get('unit')](req.args.get('interval'))
                time += delta
                time = to_utimestamp(time)
            else:
                time = to_utimestamp(parse_date(req.args.get('date')))
            origin = to_utimestamp(to_datetime(None))

            self.env.db_transaction("""
                INSERT INTO ticketreminder
                 (ticket, time, author, origin, reminded, description)
                VALUES (%s, %s, %s, %s, 0, %s)
                """, (ticket.id, time, get_reporter_id(req, 'author'),
                      origin, req.args.get('description')))

            add_notice(req, "Reminder has been added.")
            req.redirect(get_resource_url(self.env, ticket.resource, req.href) + "#reminders")

        add_script(req, 'ticketreminder/js/ticketreminder.js')

        data = {
            'ticket': ticket,
            'date_hint': get_date_format_hint(),
        }

        return ("ticket_reminder_add.html", data, None)
开发者ID:trac-hacks,项目名称:trac-ticketreminder,代码行数:29,代码来源:api.py


示例13: _get_num_closed_tix

   def _get_num_closed_tix(self, from_date, at_date, milestone, req):
      '''
      Returns an integer of the number of close ticket
      events counted between from_date to at_date.
      '''
      status_map = {'new': 0,
               'reopened': 0,
               'assigned': 0,
               'closed': 1,
               'edit': 0}

      count=0

      ma_milestone_str = ""
      if milestone != None:
         ma_milestone_str = " AND t.milestone = \"%s\" " % milestone

      db = self.env.get_db_cnx()
      cursor = db.cursor()
   
      # TODO clean up this query
      cursor.execute("SELECT t.id, tc.field, tc.time, tc.oldvalue, tc.newvalue, t.priority FROM enum p, ticket_change tc INNER JOIN ticket t ON t.id = tc.ticket AND tc.time > %s AND tc.time <= %s WHERE p.name = t.priority AND p.type = 'priority' %s ORDER BY tc.time"
                     % (to_utimestamp(from_date), to_utimestamp(at_date), ma_milestone_str))

      for id, field, time, old, status, priority in cursor:
         if field == 'status':
            if status in ('new', 'assigned', 'reopened', 'closed', 'edit'):
               count+=status_map[status]

      return count
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:ticketstats.py


示例14: test_initial_sync

    def test_initial_sync(self):
        t1 = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
        t2 = datetime(2002, 1, 1, 1, 1, 1, 0, utc)
        repos = self.get_repos(get_changeset=lambda x: changesets[int(x)], youngest_rev=1)
        changes = [
            ("trunk", Node.DIRECTORY, Changeset.ADD, None, None),
            ("trunk/README", Node.FILE, Changeset.ADD, None, None),
        ]
        changesets = [
            Mock(Changeset, repos, 0, "", "", t1, get_changes=lambda: []),
            Mock(Changeset, repos, 1, "Import", "joe", t2, get_changes=lambda: iter(changes)),
        ]
        cache = CachedRepository(self.env, repos, self.log)
        cache.sync()

        with self.env.db_query as db:
            rows = db("SELECT rev, time, author, message FROM revision")
            self.assertEquals(len(rows), 2)
            self.assertEquals(("0", to_utimestamp(t1), "", ""), rows[0])
            self.assertEquals(("1", to_utimestamp(t2), "joe", "Import"), rows[1])
            rows = db(
                """
                SELECT rev, path, node_type, change_type, base_path, base_rev
                FROM node_change"""
            )
            self.assertEquals(len(rows), 2)
            self.assertEquals(("1", "trunk", "D", "A", None, None), rows[0])
            self.assertEquals(("1", "trunk/README", "F", "A", None, None), rows[1])
开发者ID:rvelezc,项目名称:rafaelvelez.us-backup,代码行数:28,代码来源:cache.py


示例15: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        if ('sensitive_activity' in filters and
            'SENSITIVE_ACTIVITY_VIEW' in req.perm and
            'SENSITIVE_VIEW' not in req.perm):
            ts_start = to_utimestamp(start)
            ts_stop = to_utimestamp(stop)

            db = self.env.get_db_cnx()
            cursor = db.cursor()

            if 'ticket_details' in filters:
                # only show sensitive ticket changes (edits, closure) if the 'ticket_details' filter is on:
                cursor.execute("""
                    SELECT DISTINCT t.id,tc.time,tc.oldvalue
                    FROM ticket_change tc 
                        INNER JOIN ticket t ON t.id = tc.ticket 
                            AND tc.time >= %s AND tc.time <= %s  AND tc.field = %s
                        INNER JOIN ticket_custom td ON t.id = td.ticket
                            AND td.name = %s AND td.value = %s
                    ORDER BY tc.time
                    """, (ts_start, ts_stop, 'comment', 'sensitive', '1'))
                for tid,t,cid in cursor:
                    yield ('sensitive_activity', from_utimestamp(t), 'redacted', (tid, cid))
            # always show new sensitive tickets:
            cursor.execute('''
               SELECT DISTINCT id, time FROM
                  ticket t INNER JOIN ticket_custom tc ON t.id = tc.ticket
                   AND t.time >= %s AND t.time <= %s
                   AND tc.name = %s AND tc.value = %s
               ORDER BY time
               ''', (ts_start, ts_stop, 'sensitive', '1'))
            for tid,t in cursor:
                yield ('sensitive_activity', from_utimestamp(t), 'redacted', (tid, None))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:33,代码来源:sensitivetickets.py


示例16: test_missing_comment_edit

    def test_missing_comment_edit(self):
        """Modify a comment where one edit is missing"""
        ticket = Ticket(self.env, self.id)
        t1 = self.created + timedelta(seconds=70)
        ticket.modify_comment(self._find_change(ticket, 1),
                              'joe', 'New comment 1', t1)
        t2 = self.created + timedelta(seconds=80)
        ticket.modify_comment(self._find_change(ticket, 1),
                              'joe', 'Other comment 1', t2)

        self.assertChange(ticket, 1, self.t1, 'jack',
            comment=dict(author='jack', old='1', new='Other comment 1'),
            _comment0=dict(author='joe', old='Comment 1',
                           new=str(to_utimestamp(t1))),
            _comment1=dict(author='joe', old='New comment 1',
                           new=str(to_utimestamp(t2))))

        self.env.db_transaction(
            "DELETE FROM ticket_change WHERE field='_comment0'")

        t3 = self.created + timedelta(seconds=90)
        ticket.modify_comment(self._find_change(ticket, 1),
                              'joe', 'Newest comment 1', t3)

        self.assertChange(ticket, 1, self.t1, 'jack',
            comment=dict(author='jack', old='1', new='Newest comment 1'),
            _comment1=dict(author='joe', old='New comment 1',
                           new=str(to_utimestamp(t2))),
            _comment2=dict(author='joe', old='Other comment 1',
                           new=str(to_utimestamp(t3))))
开发者ID:nextview,项目名称:medicticket,代码行数:30,代码来源:model.py


示例17: test_modify_missing_cnums_and_comment

    def test_modify_missing_cnums_and_comment(self):
        """Editing a comment when all cnums are missing and one comment
        field is missing
        """
        with self.env.db_transaction as db:
            db("UPDATE ticket_change SET oldvalue='' WHERE oldvalue='1'")
            db("""DELETE FROM ticket_change
                  WHERE field='comment' AND oldvalue='1.2'""")
            db("UPDATE ticket_change SET oldvalue='' WHERE oldvalue='3'")

        # Modify after missing comment
        ticket = Ticket(self.env, self.id)
        t = self.created + timedelta(seconds=50)
        ticket.modify_comment(self._find_change(ticket, 3),
                              'joe', 'New comment 3', t)
        self.assertChange(ticket, 3, self.t3, 'jim',
            keywords=dict(author='jim', old='a, b, c', new='a, b'),
            comment=dict(author='jim', old='', new='New comment 3'),
            _comment0=dict(author='joe', old='Comment 3',
                           new=str(to_utimestamp(t))))

        # Modify missing comment
        t = self.created + timedelta(seconds=60)
        ticket.modify_comment(self._find_change(ticket, 2),
                              'joe', 'New comment 2', t)
        self.assertChange(ticket, 2, self.t2, 'john',
            owner=dict(author='john', old='john', new='jack'),
            comment=dict(author='john', old='', new='New comment 2'),
            _comment0=dict(author='joe', old='',
                           new=str(to_utimestamp(t))))
开发者ID:nextview,项目名称:medicticket,代码行数:30,代码来源:model.py


示例18: save

 def save(self, when=None):
     if when is None:
         when = self._cachetime
     when_ts = to_utimestamp(when)
     
     # Build the update/insert sequences
     # NB The ordering means the same sequences may be reused in both cases
     field_names = self.table_fields
     values_dict = dict(self.values)
     values_dict.update({'time': to_utimestamp(values_dict['time']),
                         'changetime': 
                                 to_utimestamp(values_dict['changetime']),
                         'cachetime': when_ts, 
                         'remote_name': self.remote_name, 
                         'id': self.id})
     values = [values_dict[name] for name in field_names]
     
     @self.env.with_transaction()
     def do_save(db):
         cursor = db.cursor()
         # Update the existing entry (if any)
         sql = ('''UPDATE remote_tickets SET %s
                WHERE remote_name=%%s and id=%%s''' %
                ','.join('%s=%%s' % name for name in field_names[:-2]))
         cursor.execute(sql, values)
         
         # If a row was updated then our work is done
         if cursor.rowcount > 0:
             return
         
         # If no rows were updated then this remote ticket is new to us
         sql = ('''INSERT INTO remote_tickets (%s) VALUES (%s)''' %
                (','.join(field_names),  
                 ','.join(['%s'] * len(field_names))))
         cursor.execute(sql, values)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:35,代码来源:model.py


示例19: update

    def update(self, author=None):
        """Update the milestone.
        """
        self.name = simplify_whitespace(self.name)
        if not self.name:
            raise TracError(_("Invalid milestone name."))

        old = self._old.copy()
        with self.env.db_transaction as db:
            if self.name != old['name']:
                # Update milestone field in tickets
                self.move_tickets(self.name, author, "Milestone renamed")
                # Reparent attachments
                Attachment.reparent_all(self.env, self.realm, old['name'],
                                        self.realm, self.name)

            self.env.log.info("Updating milestone '%s'", old['name'])
            db("""UPDATE milestone
                  SET name=%s, due=%s, completed=%s, description=%s
                  WHERE name=%s
                  """, (self.name, to_utimestamp(self.due),
                        to_utimestamp(self.completed),
                        self.description, old['name']))
            self.checkin()
        # Fields need reset if renamed or completed/due changed
        TicketSystem(self.env).reset_ticket_fields()

        old_values = dict((k, v) for k, v in old.iteritems()
                          if getattr(self, k) != v)
        for listener in TicketSystem(self.env).milestone_change_listeners:
            listener.milestone_changed(self, old_values)
开发者ID:pkdevbox,项目名称:trac,代码行数:31,代码来源:model.py


示例20: get_timeline_events

 def get_timeline_events(self, req, start, stop, filters):
     if 'project changes' in filters:
         cnx=self.env.get_db_cnx()
         cur=cnx.cursor()
         cur.execute("select who,change,time from project_change where time>=%s AND time<=%s"%\
                      (to_utimestamp(start), to_utimestamp(stop)));
         for who,change,ts in cur:
             yield('project',from_utimestamp(ts),who,change)
开发者ID:zjj,项目名称:ProjectsManager,代码行数:8,代码来源:projectsmanager.py



注:本文中的trac.util.datefmt.to_utimestamp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python datefmt.user_time函数代码示例发布时间:2022-05-27
下一篇:
Python datefmt.to_timestamp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap