# 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'


from utils import valid_idname, valid_guid, valid_key, reserved_word, find_key_in_query
from error import MQLParseError, MQLInternalError, MQLTypeError
from env import Guid
from pymql.util import keyquote
from pymql.log import LOG
from pymql.util.mwdatetime import coerce_datetime, uncoerce_datetime
import copy
  def addtype(self, typepath, varenv):
    if valid_idname(typepath):
      stype = SchemaType(self, None, varenv, typepath, load=False)
      self.types[typepath] = stype
      return stype
    else:
      raise MQLParseError(
          None, 'Type id %(expected_type)s is invalid', expected_type=typepath)

  # flush everything - if we have possible cache consistency issues then we should do this...
  def flush(self, varenv):
    self.init(varenv)

  # the underlying guid may have changed, properties may have been added or deleted.
  # XXX when do we call this? Right now only when we find a legal property name
  # that we couldn't resolve to solve bug 889.
  # we need a much better technique to know when types change under the schema
  # cache, but today is not that day...
  def refresh_type(self, typepath, varenv):
    if valid_idname(typepath):
      # if we found it, remove it from the cache - note that the guid may have changed too...
      # (but we won't know that unless we flush the namespace)
      if typepath in self.types:
        typeguid = self.types[typepath].guid
        del self.types[typepath]
        del self.guids[typeguid]

      # and now reload it.
      self.addtype(typepath, varenv)
    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/schema.py
from utils import valid_idname, valid_guid, valid_key, reserved_word, find_key_in_query
from error import MQLParseError, MQLInternalError, MQLTypeError
from env import Guid
from pymql.util import keyquote
from pymql.log import LOG
from pymql.util.mwdatetime import coerce_datetime, uncoerce_datetime
import copy

  def addtype(self, typepath, varenv):
    if valid_idname(typepath):
      stype = SchemaType(self, None, varenv, typepath, load=False)
      self.types[typepath] = stype
      return stype
    else:
      raise MQLParseError(
          None, 'Type id %(expected_type)s is invalid', expected_type=typepath)

  # flush everything - if we have possible cache consistency issues then we should do this...
  def flush(self, varenv):
    self.init(varenv)

  # the underlying guid may have changed, properties may have been added or deleted.
  # XXX when do we call this? Right now only when we find a legal property name
  # that we couldn't resolve to solve bug 889.
  # we need a much better technique to know when types change under the schema
  # cache, but today is not that day...
  def refresh_type(self, typepath, varenv):
    if valid_idname(typepath):
      # if we found it, remove it from the cache - note that the guid may have changed too...
      # (but we won't know that unless we flush the namespace)
      if typepath in self.types:
        typeguid = self.types[typepath].guid
        del self.types[typepath]
        del self.guids[typeguid]

      # and now reload it.
      self.addtype(typepath, varenv)
    else:

      raise MQLParseError(