# Path: error.py
# def is_valid_HTTP_code(code):
# def get_HTTP_err(code):
#   def __init__(self,
#                msg,
#                http_code=400,
#                app_code=DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def gen_msgs(self, **kwds):
#   def get_err_dict(self):
#   def __str__(self):
#   def __init__(self,
#                msg,
#                http_code=500,
#                app_code=ParameterizedError.DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def __init__(self, msg=None, *args, **kwds):
# class ParameterizedError(Exception):
# class NetworkAddressError(ParameterizedError):
# class ContentLoadError(ParameterizedError):
# class TypeVerifyError(ParameterizedError):
# class EmailError(ParameterizedError):
# class SubscriptionError(ParameterizedError):
# class MSSError(ParameterizedError):
# class UserLookupError(ParameterizedError):
# class UserAuthError(ParameterizedError):
# class BlobError(ParameterizedError):
# class BLOBClientError(ParameterizedError):
# class RelevanceError(ParameterizedError):
# class TextSearchError(ParameterizedError):
# class AutocompleteError(ParameterizedError):
# class EmptyResult(ParameterizedError):
# class GraphConnectionError(ParameterizedError):
# class FormattingError(ParameterizedError):
# class SessionError(ParameterizedError):
# class ConfigError(ParameterizedError):
# class SanitizationError(ParameterizedError):
# class BlurbError(ParameterizedError):
# class DomainOperationError(ParameterizedError):
# class GenericRuntimeError(ParameterizedError):
# class OAuthDisabledError(ParameterizedError):
# class RecaptchaError(ParameterizedError):
# class ReadOnlyDatabaseError(ParameterizedError):
#   DEF_PFX = '/api/status/error'
#   DEF_ME_CODE = '/unknown/unknown'


import re
  import sys, os
import json
import scope
import lookup
import pprint
import cgi
  import cmdline
from pymql.log import LOG, log_util, pprintlog, dumplog
from pymql.error import EmptyResult
from qprim import QueryPrimitive
from utils import (element, elements, dict_recurse, valid_relname, follow_path,
                   is_direct_pointer, valid_precompiled_sort, ReadMode,
                   WriteMode, PrepareMode, CheckMode, QueryDict, QueryList,
                   ResultDict, Missing)
from error import MQLResultError, MQLInternalError, MQLInternalParseError, MQLAccessError, MQLGraphError
from env import Varenv
            raise MQLAccessError(
                query,
                'User %(user)s cannot create with permission %(permission)s',
                user=varenv.get_user_id(),
                permission=permissionguid)
            # *****************************************************************************************************************

        elif node.state == 'remove':
          if node.guid in (None, Missing):
            raise MQLInternalError(
                query, 'Found node with guid=null but state=remove')

          if node.scope in (None, Missing):
            raise MQLInternalError(
                query,
                'Found node with guid %(guid)s but scope=null during check_write_access()',
                guid=node.guid)

          node_permission = query['+has_permission'].node.guid
          if scope.check_permission(
              self, varenv, permissionguid=node_permission):
            node.scope = varenv.attribution_guid
            node.access_control_ok = True

            # we'll need to remove the permission link for this node.
            query['+has_permission'].link.scope = varenv.attribution_guid
            query['+has_permission'].link.access_control_ok = True

          else:
            # *****************************************************************************************************************

# Path: error.py
# def is_valid_HTTP_code(code):
# def get_HTTP_err(code):
#   def __init__(self,
#                msg,
#                http_code=400,
#                app_code=DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def gen_msgs(self, **kwds):
#   def get_err_dict(self):
#   def __str__(self):
#   def __init__(self,
#                msg,
#                http_code=500,
#                app_code=ParameterizedError.DEF_ME_CODE,
#                inner_exc=None,
#                **kwds):
#   def __init__(self, msg=None, *args, **kwds):
# class ParameterizedError(Exception):
# class NetworkAddressError(ParameterizedError):
# class ContentLoadError(ParameterizedError):
# class TypeVerifyError(ParameterizedError):
# class EmailError(ParameterizedError):
# class SubscriptionError(ParameterizedError):
# class MSSError(ParameterizedError):
# class UserLookupError(ParameterizedError):
# class UserAuthError(ParameterizedError):
# class BlobError(ParameterizedError):
# class BLOBClientError(ParameterizedError):
# class RelevanceError(ParameterizedError):
# class TextSearchError(ParameterizedError):
# class AutocompleteError(ParameterizedError):
# class EmptyResult(ParameterizedError):
# class GraphConnectionError(ParameterizedError):
# class FormattingError(ParameterizedError):
# class SessionError(ParameterizedError):
# class ConfigError(ParameterizedError):
# class SanitizationError(ParameterizedError):
# class BlurbError(ParameterizedError):
# class DomainOperationError(ParameterizedError):
# class GenericRuntimeError(ParameterizedError):
# class OAuthDisabledError(ParameterizedError):
# class RecaptchaError(ParameterizedError):
# class ReadOnlyDatabaseError(ParameterizedError):
#   DEF_PFX = '/api/status/error'
#   DEF_ME_CODE = '/unknown/unknown'


# Path: mql/lojson.py
import re
  import sys, os
import json
import scope
import lookup
import pprint
import cgi
  import cmdline
from pymql.log import LOG, log_util, pprintlog, dumplog
from pymql.error import EmptyResult
from qprim import QueryPrimitive
from utils import (element, elements, dict_recurse, valid_relname, follow_path,
                   is_direct_pointer, valid_precompiled_sort, ReadMode,
                   WriteMode, PrepareMode, CheckMode, QueryDict, QueryList,
                   ResultDict, Missing)
from error import MQLResultError, MQLInternalError, MQLInternalParseError, MQLAccessError, MQLGraphError
from env import Varenv

            raise MQLAccessError(
                query,
                'User %(user)s cannot create with permission %(permission)s',
                user=varenv.get_user_id(),
                permission=permissionguid)
            # *****************************************************************************************************************

        elif node.state == 'remove':
          if node.guid in (None, Missing):
            raise MQLInternalError(
                query, 'Found node with guid=null but state=remove')

          if node.scope in (None, Missing):
            raise MQLInternalError(
                query,
                'Found node with guid %(guid)s but scope=null during check_write_access()',
                guid=node.guid)

          node_permission = query['+has_permission'].node.guid
          if scope.check_permission(
              self, varenv, permissionguid=node_permission):
            node.scope = varenv.attribution_guid
            node.access_control_ok = True

            # we'll need to remove the permission link for this node.
            query['+has_permission'].link.scope = varenv.attribution_guid
            query['+has_permission'].link.access_control_ok = True

          else:
            # *****************************************************************************************************************

            raise MQLAccessError(