Пример #1
0
Файл: views.py Проект: ztwu/hue
def edit_as_text(request, id, path):
    cluster = get_cluster_or_404(id)
    zk = ZooKeeper(cluster['rest_url'])
    node = zk.get(path)

    if request.method == 'POST':
        if not request.user.is_superuser:
            raise PopupException(_('You are not a superuser'))
        form = EditZNodeForm(request.POST)
        if form.is_valid():
            zk.set(path, form.cleaned_data['data'])

        return tree(request, id, path)
    else:
        form = EditZNodeForm(
            dict(data=node.get('data64', '').decode('base64').strip(),
                 version=node.get('version', '-1')))

    return render(
        'edit.mako', request, {
            'cluster': cluster,
            'path': path,
            'form': form,
            'clusters': CLUSTERS.get(),
        })
Пример #2
0
def edit_as_base64(request, id, path):
    cluster = get_cluster_or_404(id)
    zk = ZooKeeper(cluster['rest_url'])
    node = zk.get(path)

    if request.method == 'POST':
        form = EditZNodeForm(request.POST)
        if form.is_valid():
            # TODO is valid base64 string?
            data = form.cleaned_data['data'].decode('base64')
            zk.set(path, data, form.cleaned_data['version'])

        return tree(request, id, path)
    else:
        form = EditZNodeForm(dict(\
          data=node.get('data64', ''),
          version=node.get('version', '-1')))

    return render(
        'edit.mako', request, {
            'cluster': cluster,
            'path': path,
            'form': form,
            'clusters': CLUSTERS.get(),
        })
Пример #3
0
def edit_as_text(request, id, path):
  cluster = get_cluster_or_404(id)
  zk = ZooKeeper(cluster['rest_url'])
  node = zk.get(path)

  if request.method == 'POST':
    form = EditZNodeForm(request.POST)
    if form.is_valid():
      zk.set(path, form.cleaned_data['data'])

    return tree(request, id, path)
  else:
    form = EditZNodeForm(dict(data=node.get('data64', '').decode('base64').strip(), version=node.get('version', '-1')))

  return render('edit.mako', request, {'cluster': cluster, 'path': path, 'form': form, 'clusters': CLUSTERS.get(),})
Пример #4
0
def edit_as_base64(request, id, path):
  cluster = get_cluster_or_404(id)
  zk = ZooKeeper(cluster['rest_url'])
  node = zk.get(path)

  if request.method == 'POST':
    if not request.user.is_superuser:
      raise PopupException(_('You are not a superuser'))
    form = EditZNodeForm(request.POST)
    if form.is_valid():
      # TODO is valid base64 string?
      data = form.cleaned_data['data'].decode('base64')
      zk.set(path, data, form.cleaned_data['version'])

    return tree(request, id, path)
  else:
    form = EditZNodeForm(dict(\
      data=node.get('data64', ''),
      version=node.get('version', '-1')))

  return render('edit.mako', request, {'cluster': cluster, 'path': path, 'form': form, 'clusters': CLUSTERS.get(),})