duhuilin01 发表于 2013-1-29 23:21:21

wiki配置管理

Make sure your data directory path is correct, check permissions, and
that the data/plugin directory has an __init__.py file.
""" % {
    'path': pdir,
    'err': str(err),
}
            raise error.ConfigurationError(msg)

    def _fillDicts(self):
      """ fill config dicts

      Fills in missing dict keys of derived user config by copying
      them from this base class.
      """
      # user checkbox defaults
      for key, value in DefaultConfig.user_checkbox_defaults.items():
            if key not in self.user_checkbox_defaults:
                self.user_checkbox_defaults = value

    def __getitem__(self, item):
      """ Make it possible to access a config object like a dict """
      return getattr(self, item)


class DefaultConfig(ConfigFunctionality):
    """ Configuration base class with default config values
      (added below)
    """
    # Do not add anything into this class. Functionality must
    # be added above to avoid having the methods show up in
    # the WikiConfig macro. Settings must be added below to
    # the options dictionary.


def _default_password_checker(cfg, request, username, password):
    """ Check if a password is secure enough.
      We use a built-in check to get rid of the worst passwords.

      We do NOT use cracklib / python-crack here any more because it is
      not thread-safe (we experienced segmentation faults when using it).

      If you don't want to check passwords, use password_checker = None.

      @return: None if there is no problem with the password,
               some unicode object with an error msg, if the password is problematic.
    """
    _ = request.getText
    # in any case, do a very simple built-in check to avoid the worst passwords
    if len(password) < 6:
      return _("Password is too short.")
    if len(set(password)) < 4:
      return _("Password has not enough different characters.")

    username_lower = username.lower()
    password_lower = password.lower()
    if username in password or password in username or \
       username_lower in password_lower or password_lower in username_lower:
      return _("Password is too easy (password contains name or name contains password).")

    keyboards = (ur"`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./", # US kbd
               ur"^1234567890叽qwertzuiop?asdfghjkl鲣#yxcvbnm,.-", # german kbd
                ) # add more keyboards!
    for kbd in keyboards:
      rev_kbd = kbd[::-1]
      if password in kbd or password in rev_kbd or \
         password_lower in kbd or password_lower in rev_kbd:
            return _("Password is too easy (keyboard sequence).")
    return None


class DefaultExpression(object):
    def __init__(self, exprstr):
      self.text = exprstr
      self.value = eval(exprstr)


#
# Options that are not prefixed automatically with their
# group name, see below (at the options dict) for more
# information on the layout of this structure.
#
页: [1]
查看完整版本: wiki配置管理