示例#1
0
  def NextChunk(self, rpc_controller, req, done):
    if not self.http_request.user_is_admin:
      raise GetLostError()

    rsp = NextChunkResponse()

    try:
      cls = KINDS[req.kind]
    except KeyError:
      done(rsp)
      return

    if req.last_key:
      q = models.gql(cls,
                     'WHERE __key__ > :1 ORDER BY __key__',
                      db.Key(req.last_key))
    else:
      q = models.gql(cls, 'ORDER BY __key__')

    sz = 20
    for o in q.fetch(sz):
      e = rsp.entity.add()
      if o.key().id() is not None:
        e.key_id = o.key().id()
      if o.key().name() is not None:
        e.key_name = o.key().name()
      e.key = str(o.key())
      e.last_backed_up = o.last_backed_up

      buf = cStringIO.StringIO()
      pickle.dump(o, buf, -1)
      e.data = buf.getvalue()
    done(rsp)
示例#2
0
    def NextChunk(self, rpc_controller, req, done):
        if not self.http_request.user_is_admin:
            raise GetLostError()

        rsp = NextChunkResponse()

        try:
            cls = KINDS[req.kind]
        except KeyError:
            done(rsp)
            return

        if req.last_key:
            q = models.gql(cls, 'WHERE __key__ > :1 ORDER BY __key__',
                           db.Key(req.last_key))
        else:
            q = models.gql(cls, 'ORDER BY __key__')

        sz = 20
        for o in q.fetch(sz):
            e = rsp.entity.add()
            if o.key().id() is not None:
                e.key_id = o.key().id()
            if o.key().name() is not None:
                e.key_name = o.key().name()
            e.key = str(o.key())
            e.last_backed_up = o.last_backed_up

            buf = cStringIO.StringIO()
            pickle.dump(o, buf, -1)
            e.data = buf.getvalue()
        done(rsp)
示例#3
0
    def _lock_next_new_imp(cls):
        for attempt in xrange(5):
            ro_rb = gql(cls, "WHERE state = :1 ORDER BY created", ReceivedBundle.STATE_NEW).get()
            if ro_rb is None:
                return None

            def trans(key):
                rb = db.get(key)
                if rb.state == ReceivedBundle.STATE_NEW:
                    rb.state = ReceivedBundle.STATE_UNPACKING
                    rb.put()
                    return True
                return False

            if db.run_in_transaction(trans, ro_rb.key()):
                return ro_rb
        return None
示例#4
0
    def _lock_next_new_imp(cls):
        for attempt in xrange(5):
            ro_rb = gql(cls, "WHERE state = :1 ORDER BY created",
                        ReceivedBundle.STATE_NEW).get()
            if ro_rb is None:
                return None

            def trans(key):
                rb = db.get(key)
                if rb.state == ReceivedBundle.STATE_NEW:
                    rb.state = ReceivedBundle.STATE_UNPACKING
                    rb.put()
                    return True
                return False

            if db.run_in_transaction(trans, ro_rb.key()):
                return ro_rb
        return None
示例#5
0
文件: people.py 项目: Shrews/PyGerrit
def admin_unverified_clas(request):
  """/admin/unverified_clas - list of users who need CLAs"""
  max = 100
  first_email = request.GET.get('first', '')
  unverified_users = models.gql(models.Account,
                                'WHERE welcomed = True'
                                ' AND cla_verified = False'
                                ' AND email >= :1'
                                ' ORDER BY email',
                                first_email).fetch(max + 1)
  if len(unverified_users) > max:
    next_email = unverified_users[-1].email
    unverified_users = unverified_users[:-1]
  else:
    next_email = None
  return respond(request, 'admin_unverified_clas.html', {
                 'unverified_users': unverified_users,
                 'next_email': next_email,
                 'next_size': max,
                 })
示例#6
0
def admin_unverified_clas(request):
    """/admin/unverified_clas - list of users who need CLAs"""
    max = 100
    first_email = request.GET.get('first', '')
    unverified_users = models.gql(
        models.Account, 'WHERE welcomed = True'
        ' AND cla_verified = False'
        ' AND email >= :1'
        ' ORDER BY email', first_email).fetch(max + 1)
    if len(unverified_users) > max:
        next_email = unverified_users[-1].email
        unverified_users = unverified_users[:-1]
    else:
        next_email = None
    return respond(
        request, 'admin_unverified_clas.html', {
            'unverified_users': unverified_users,
            'next_email': next_email,
            'next_size': max,
        })
示例#7
0
文件: people.py 项目: Shrews/PyGerrit
def _get_groups_for_account(account):
  return models.gql(models.AccountGroup,
                    'WHERE members = :1',
                    account.user).fetch(models.FETCH_MAX)
示例#8
0
def _get_groups_for_account(account):
    return models.gql(models.AccountGroup, 'WHERE members = :1',
                      account.user).fetch(models.FETCH_MAX)