import os
import time
import datetime
import urllib
import urllib2
from rhodecode.lib.vcs.backends.base import BaseRepository
from .workdir import MercurialWorkdir
from .changeset import MercurialChangeset
from .inmemory import MercurialInMemoryChangeset
from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError, \
ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, \
VCSError, TagAlreadyExistError, TagDoesNotExistError
from rhodecode.lib.vcs.utils import author_email, author_name, date_fromtimestamp, \
makedate, safe_unicode
from rhodecode.lib.vcs.utils.lazy import LazyProperty
from rhodecode.lib.vcs.utils.ordered_dict import OrderedDict
from rhodecode.lib.vcs.utils.paths import abspath
from rhodecode.lib.vcs.utils.hgcompat import ui, nullid, match, patch, diffopts, clone, \
get_contact, pull, localrepository, RepoLookupError, Abort, RepoError, hex
class MercurialRepository(BaseRepository):
"""
Mercurial repository backend
DEFAULT_BRANCH_NAME = 'default'
scm = 'hg'
def __init__(self, repo_path, create=False, baseui=None, src_url=None,
update_after_clone=False):
Raises RepositoryError if repository could not be find at the given
``repo_path``.
:param repo_path: local path of the repository
:param create=False: if set to True, would try to create repository if
it does not exist rather than raising exception
:param baseui=None: user data
:param src_url=None: would try to clone repository from given location
:param update_after_clone=False: sets update of working copy after
making a clone
if not isinstance(repo_path, str):
raise VCSError('Mercurial backend requires repository path to '
'be instance of <str> got %s instead' %
type(repo_path))
self.path = abspath(repo_path)
self.baseui = baseui or ui.ui()
# We've set path and ui, now we can set _repo itself
self._repo = self._get_repo(create, src_url, update_after_clone)
@property
def _empty(self):
Checks if repository is empty without any changesets
# TODO: Following raises errors when using InMemoryChangeset...
# return len(self._repo.changelog) == 0
return len(self.revisions) == 0
@LazyProperty
def revisions(self):
Returns list of revisions' ids, in ascending order. Being lazy
attribute allows external tools to inject shas from cache.
return self._get_all_revisions()
def name(self):
return os.path.basename(self.path)
def branches(self):
return self._get_branches()
def _get_branches(self, closed=False):
Get's branches for this repository
Returns only not closed branches by default
:param closed: return also closed branches for mercurial
if self._empty:
return {}
def _branchtags(localrepo):
Patched version of mercurial branchtags to not return the closed
branches
:param localrepo: locarepository instance
bt = {}
bt_closed = {}
for bn, heads in localrepo.branchmap().iteritems():
tip = heads[-1]
if 'close' in localrepo.changelog.read(tip)[5]:
bt_closed[bn] = tip
else:
bt[bn] = tip
if closed:
bt.update(bt_closed)
return bt
sortkey = lambda ctx: ctx[0] # sort by name
_branches = [(safe_unicode(n), hex(h),) for n, h in
_branchtags(self._repo).items()]
return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
def tags(self):
Get's tags for this repository
return self._get_tags()
def _get_tags(self):
_tags = [(safe_unicode(n), hex(h),) for n, h in
self._repo.tags().items()]
return OrderedDict(sorted(_tags, key=sortkey, reverse=True))
def tag(self, name, user, revision=None, message=None, date=None,
**kwargs):
Creates and returns a tag for the given ``revision``.
:param name: name for new tag
:param user: full username, i.e.: "Joe Doe <joe.doe@example.com>"
:param revision: changeset id for which new tag would be created
:param message: message of the tag's commit
:param date: date of tag's commit
:raises TagAlreadyExistError: if tag with same name already exists
if name in self.tags:
raise TagAlreadyExistError("Tag %s already exists" % name)
changeset = self.get_changeset(revision)
local = kwargs.setdefault('local', False)
if message is None:
message = "Added tag %s for changeset %s" % (name,
changeset.short_id)
if date is None:
date = datetime.datetime.now().ctime()
try:
self._repo.tag(name, changeset._ctx.node(), message, local, user,
date)
except Abort, e:
raise RepositoryError(e.message)
# Reinitialize tags
self.tags = self._get_tags()
tag_id = self.tags[name]
return self.get_changeset(revision=tag_id)
def remove_tag(self, name, user, message=None, date=None):
Removes tag with the given ``name``.
:param name: name of the tag to be removed
:param message: message of the tag's removal commit
:param date: date of tag's removal commit
:raises TagDoesNotExistError: if tag with given name does not exists
if name not in self.tags:
raise TagDoesNotExistError("Tag %s does not exist" % name)
message = "Removed tag %s" % name
local = False
self._repo.tag(name, nullid, message, local, user, date)
def bookmarks(self):
Get's bookmarks for this repository
return self._get_bookmarks()
def _get_bookmarks(self):
_bookmarks = [(safe_unicode(n), hex(h),) for n, h in
self._repo._bookmarks.items()]
return OrderedDict(sorted(_bookmarks, key=sortkey, reverse=True))
def _get_all_revisions(self):
return map(lambda x: hex(x[7]), self._repo.changelog.index)[:-1]
def get_diff(self, rev1, rev2, path='', ignore_whitespace=False,
context=3):
Returns (git like) *diff*, as plain text. Shows changes introduced by
``rev2`` since ``rev1``.
:param rev1: Entry point from which diff is shown. Can be
``self.EMPTY_CHANGESET`` - in this case, patch showing all
the changes since empty state of the repository until ``rev2``
:param rev2: Until which revision changes should be shown.
:param ignore_whitespace: If set to ``True``, would not show whitespace
changes. Defaults to ``False``.
:param context: How many lines before/after changed lines should be
shown. Defaults to ``3``.
if hasattr(rev1, 'raw_id'):
rev1 = getattr(rev1, 'raw_id')
if hasattr(rev2, 'raw_id'):
rev2 = getattr(rev2, 'raw_id')
# Check if given revisions are present at repository (may raise
# ChangesetDoesNotExistError)
if rev1 != self.EMPTY_CHANGESET:
self.get_changeset(rev1)
self.get_changeset(rev2)
file_filter = match(self.path, '', [path])
return ''.join(patch.diff(self._repo, rev1, rev2, match=file_filter,
opts=diffopts(git=True,
ignorews=ignore_whitespace,
context=context)))
def _check_url(self, url):
Function will check given url and try to verify if it's a valid
link. Sometimes it may happened that mercurial will issue basic
auth request that can cause whole API to hang when used from python
or other external calls.
On failures it'll raise urllib2.HTTPError, return code 200 if url
is valid or True if it's a local path
from mercurial.util import url as Url
# those authnadlers are patched for python 2.6.5 bug an
# infinit looping when given invalid resources
from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
# check first if it's not an local url
if os.path.isdir(url) or url.startswith('file:'):
return True
if('+' in url[:url.find('://')]):
url = url[url.find('+')+1:]
handlers = []
test_uri, authinfo = Url(url).authinfo()
if authinfo:
#create a password manager
passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
passmgr.add_password(*authinfo)
handlers.extend((httpbasicauthhandler(passmgr),
httpdigestauthhandler(passmgr)))
o = urllib2.build_opener(*handlers)
o.addheaders = [('Content-Type', 'application/mercurial-0.1'),
('Accept', 'application/mercurial-0.1')]
q = {"cmd": 'between'}
q.update({'pairs': "%s-%s" % ('0' * 40, '0' * 40)})
qs = '?%s' % urllib.urlencode(q)
cu = "%s%s" % (test_uri, qs)
req = urllib2.Request(cu, None, {})
resp = o.open(req)
return resp.code == 200
except Exception, e:
# means it cannot be cloned
raise urllib2.URLError(e)
def _get_repo(self, create, src_url=None, update_after_clone=False):
Function will check for mercurial repository in given path and return
a localrepo object. If there is no repository in that path it will
raise an exception unless ``create`` parameter is set to True - in
that case repository would be created and returned.
If ``src_url`` is given, would try to clone repository from the
location at given clone_point. Additionally it'll make update to
working copy accordingly to ``update_after_clone`` flag
if src_url:
url = str(self._get_url(src_url))
opts = {}
if not update_after_clone:
opts.update({'noupdate': True})
self._check_url(url)
clone(self.baseui, url, self.path, **opts)
# except urllib2.URLError:
# raise Abort("Got HTTP 404 error")
except Exception:
raise
# Don't try to create if we've already cloned repo
create = False
return localrepository(self.baseui, self.path, create=create)
except (Abort, RepoError), err:
if create:
msg = "Cannot create repository at %s. Original error was %s"\
% (self.path, err)
msg = "Not valid repository at %s. Original error was %s"\
raise RepositoryError(msg)
def in_memory_changeset(self):
return MercurialInMemoryChangeset(self)
def description(self):
undefined_description = u'unknown'
return safe_unicode(self._repo.ui.config('web', 'description',
undefined_description, untrusted=True))
def contact(self):
undefined_contact = u'Unknown'
return safe_unicode(get_contact(self._repo.ui.config)
or undefined_contact)
def last_change(self):
Returns last change made on this repository as datetime object
return date_fromtimestamp(self._get_mtime(), makedate()[1])
def _get_mtime(self):
return time.mktime(self.get_changeset().date.timetuple())
except RepositoryError:
#fallback to filesystem
cl_path = os.path.join(self.path, '.hg', "00changelog.i")
st_path = os.path.join(self.path, '.hg', "store")
if os.path.exists(cl_path):
return os.stat(cl_path).st_mtime
return os.stat(st_path).st_mtime
def _get_hidden(self):
return self._repo.ui.configbool("web", "hidden", untrusted=True)
def _get_revision(self, revision):
Get's an ID revision given as str. This will always return a fill
40 char revision number
:param revision: str or int or None
raise EmptyRepositoryError("There are no changesets yet")
if revision in [-1, 'tip', None]:
revision = 'tip'
revision = hex(self._repo.lookup(revision))
except (IndexError, ValueError, RepoLookupError, TypeError):
raise ChangesetDoesNotExistError("Revision %r does not "
"exist for this repository %s" \
% (revision, self))
return revision
def _get_archives(self, archive_name='tip'):
allowed = self.baseui.configlist("web", "allow_archive",
untrusted=True)
for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
if i[0] in allowed or self._repo.ui.configbool("web",
"allow" + i[0],
untrusted=True):
yield {"type": i[0], "extension": i[1], "node": archive_name}
def _get_url(self, url):
Returns normalized url. If schema is not given, would fall
to filesystem
(``file:///``) schema.
url = str(url)
if url != 'default' and not '://' in url:
url = "file:" + urllib.pathname2url(url)
return url
def get_changeset(self, revision=None):
Returns ``MercurialChangeset`` object representing repository's
changeset at the given ``revision``.
revision = self._get_revision(revision)
changeset = MercurialChangeset(repository=self, revision=revision)
return changeset
def get_changesets(self, start=None, end=None, start_date=None,
end_date=None, branch_name=None, reverse=False):
Returns iterator of ``MercurialChangeset`` objects from start to end
(both are inclusive)
:param start: None, str, int or mercurial lookup format
:param end: None, str, int or mercurial lookup format
:param start_date:
:param end_date:
:param branch_name:
:param reversed: return changesets in reversed order
start_raw_id = self._get_revision(start)
start_pos = self.revisions.index(start_raw_id) if start else None
end_raw_id = self._get_revision(end)
end_pos = self.revisions.index(end_raw_id) if end else None
if None not in [start, end] and start_pos > end_pos:
raise RepositoryError("start revision '%s' cannot be "
"after end revision '%s'" % (start, end))
if branch_name and branch_name not in self.branches.keys():
raise BranchDoesNotExistError('Such branch %s does not exists for'
' this repository' % branch_name)
if end_pos is not None:
end_pos += 1
slice_ = reversed(self.revisions[start_pos:end_pos]) if reverse else \
self.revisions[start_pos:end_pos]
for id_ in slice_:
cs = self.get_changeset(id_)
if branch_name and cs.branch != branch_name:
continue
if start_date and cs.date < start_date:
if end_date and cs.date > end_date:
yield cs
def pull(self, url):
Tries to pull changes from external location.
url = self._get_url(url)
pull(self.baseui, self._repo, url)
except Abort, err:
# Propagate error but with vcs's type
raise RepositoryError(str(err))
def workdir(self):
Returns ``Workdir`` instance for this repository.
return MercurialWorkdir(self)
def get_config_value(self, section, name, config_file=None):
Returns configuration value for a given [``section``] and ``name``.
:param section: Section we want to retrieve value from
:param name: Name of configuration we want to retrieve
:param config_file: A path to file which should be used to retrieve
configuration from (might also be a list of file paths)
if config_file is None:
config_file = []
elif isinstance(config_file, basestring):
config_file = [config_file]
config = self._repo.ui
for path in config_file:
config.readconfig(path)
return config.config(section, name)
def get_user_name(self, config_file=None):
Returns user's name from global configuration file.
username = self.get_config_value('ui', 'username')
if username:
return author_name(username)
return None
def get_user_email(self, config_file=None):
Returns user's email from global configuration file.
return author_email(username)
Set of generic validators
import re
import formencode
import logging
from pylons.i18n.translation import _
from webhelpers.pylonslib.secure_form import authentication_token
from formencode.validators import (
UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set
)
from rhodecode.lib.utils import repo_name_slug
from rhodecode.model.db import RepoGroup, Repository, UsersGroup, User
from rhodecode.lib.exceptions import LdapImportError
from rhodecode.config.routing import ADMIN_PREFIX
# silence warnings and pylint
log = logging.getLogger(__name__)
class StateObj(object):
this is needed to translate the messages using _() in validators
_ = staticmethod(_)
def M(self, key, state=None, **kwargs):
returns string from self.message based on given key,
passed kw params are used to substitute %(named)s params inside
translated strings
:param msg:
:param state:
if state is None:
state = StateObj()
state._ = staticmethod(_)
#inject validator into state object
return self.message(key, state, **kwargs)
def ValidUsername(edit=False, old_data={}):
class _validator(formencode.validators.FancyValidator):
messages = {
'username_exists': _(u'Username "%(username)s" already exists'),
'system_invalid_username':
_(u'Username "%(username)s" is forbidden'),
'invalid_username':
_(u'Username may only contain alphanumeric characters '
'underscores, periods or dashes and must begin with '
'alphanumeric character')
}
def validate_python(self, value, state):
if value in ['default', 'new_user']:
msg = M(self, 'system_invalid_username', state, username=value)
raise formencode.Invalid(msg, value, state)
#check if user is unique
old_un = None
if edit:
old_un = User.get(old_data.get('user_id')).username
if old_un != value or not edit:
if User.get_by_username(value, case_insensitive=True):
msg = M(self, 'username_exists', state, username=value)
if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
msg = M(self, 'invalid_username', state)
return _validator
def ValidRepoUser():
'invalid_username': _(u'Username %(username)s is not valid')
User.query().filter(User.active == True)\
.filter(User.username == value).one()
msg = M(self, 'invalid_username', state, username=value)
raise formencode.Invalid(msg, value, state,
error_dict=dict(username=msg)
def ValidUsersGroup(edit=False, old_data={}):
'invalid_group': _(u'Invalid users group name'),
'group_exist': _(u'Users group "%(usersgroup)s" already exists'),
'invalid_usersgroup_name':
_(u'users group name may only contain alphanumeric '
'characters underscores, periods or dashes and must begin '
'with alphanumeric character')
if value in ['default']:
msg = M(self, 'invalid_group', state)
error_dict=dict(users_group_name=msg)
#check if group is unique
old_ugname = None
old_id = old_data.get('users_group_id')
old_ugname = UsersGroup.get(old_id).users_group_name
if old_ugname != value or not edit:
is_existing_group = UsersGroup.get_by_group_name(value,
case_insensitive=True)
if is_existing_group:
msg = M(self, 'group_exist', state, usersgroup=value)
msg = M(self, 'invalid_usersgroup_name', state)
def ValidReposGroup(edit=False, old_data={}):
'group_parent_id': _(u'Cannot assign this group as parent'),
'group_exists': _(u'Group "%(group_name)s" already exists'),
'repo_exists':
_(u'Repository with name "%(group_name)s" already exists')
# TODO WRITE VALIDATIONS
group_name = value.get('group_name')
group_parent_id = value.get('group_parent_id')
# slugify repo group just in case :)
slug = repo_name_slug(group_name)
# check for parent of self
parent_of_self = lambda: (
old_data['group_id'] == int(group_parent_id)
if group_parent_id else False
if edit and parent_of_self():
msg = M(self, 'group_parent_id', state)
error_dict=dict(group_parent_id=msg)
old_gname = None
old_gname = RepoGroup.get(old_data.get('group_id')).group_name
if old_gname != group_name or not edit:
# check group
gr = RepoGroup.query()\
.filter(RepoGroup.group_name == slug)\
.filter(RepoGroup.group_parent_id == group_parent_id)\
.scalar()
if gr:
msg = M(self, 'group_exists', state, group_name=slug)
error_dict=dict(group_name=msg)
# check for same repo
repo = Repository.query()\
.filter(Repository.repo_name == slug)\
if repo:
msg = M(self, 'repo_exists', state, group_name=slug)
def ValidPassword():
'invalid_password':
_(u'Invalid characters (non-ascii) in password')
(value or '').decode('ascii')
except UnicodeError:
msg = M(self, 'invalid_password', state)
raise formencode.Invalid(msg, value, state,)
def ValidPasswordsMatch():
'password_mismatch': _(u'Passwords do not match'),
pass_val = value.get('password') or value.get('new_password')
if pass_val != value['password_confirmation']:
msg = M(self, 'password_mismatch', state)
error_dict=dict(password_confirmation=msg)
def ValidAuth():
'invalid_password': _(u'invalid password'),
'invalid_username': _(u'invalid user name'),
'disabled_account': _(u'Your account is disabled')
from rhodecode.lib.auth import authenticate
password = value['password']
username = value['username']
if not authenticate(username, password):
user = User.get_by_username(username)
if user and user.active is False:
log.warning('user %s is disabled' % username)
msg = M(self, 'disabled_account', state)
log.warning('user %s failed to authenticate' % username)
msg2 = M(self, 'invalid_password', state)
error_dict=dict(username=msg, password=msg2)
def ValidAuthToken():
'invalid_token': _(u'Token mismatch')
if value != authentication_token():
msg = M(self, 'invalid_token', state)
def ValidRepoName(edit=False, old_data={}):
'invalid_repo_name':
_(u'Repository name %(repo)s is disallowed'),
'repository_exists':
_(u'Repository named %(repo)s already exists'),
'repository_in_group_exists': _(u'Repository "%(repo)s" already '
'exists in group "%(group)s"'),
'same_group_exists': _(u'Repositories group with name "%(repo)s" '
'already exists')
def _to_python(self, value, state):
repo_name = repo_name_slug(value.get('repo_name', ''))
repo_group = value.get('repo_group')
if repo_group:
gr = RepoGroup.get(repo_group)
group_path = gr.full_path
group_name = gr.group_name
# value needs to be aware of group name in order to check
# db key This is an actual just the name to store in the
# database
repo_name_full = group_path + RepoGroup.url_sep() + repo_name
group_name = group_path = ''
repo_name_full = repo_name
value['repo_name'] = repo_name
value['repo_name_full'] = repo_name_full
value['group_path'] = group_path
value['group_name'] = group_name
return value
repo_name = value.get('repo_name')
repo_name_full = value.get('repo_name_full')
group_path = value.get('group_path')
if repo_name in [ADMIN_PREFIX, '']:
msg = M(self, 'invalid_repo_name', state, repo=repo_name)
error_dict=dict(repo_name=msg)
rename = old_data.get('repo_name') != repo_name_full
create = not edit
if rename or create:
if group_path != '':
if Repository.get_by_repo_name(repo_name_full):
msg = M(self, 'repository_in_group_exists', state,
repo=repo_name, group=group_name)
elif RepoGroup.get_by_group_name(repo_name_full):
msg = M(self, 'same_group_exists', state,
repo=repo_name)
elif Repository.get_by_repo_name(repo_name_full):
msg = M(self, 'repository_exists', state,
def ValidForkName(*args, **kwargs):
return ValidRepoName(*args, **kwargs)
def SlugifyName():
return repo_name_slug(value)
pass
def ValidCloneUri():
from rhodecode.lib.utils import make_ui
def url_handler(repo_type, url, proto, ui=None):
def url_handler(repo_type, url, ui=None):
if repo_type == 'hg':
from mercurial.httprepo import httprepository, httpsrepository
if proto == 'https':
if url.startswith('https'):
httpsrepository(make_ui('db'), url).capabilities
elif proto == 'http':
elif url.startswith('http'):
httprepository(make_ui('db'), url).capabilities
elif url.startswith('svn+http'):
from hgsubversion.svnrepo import svnremoterepo
svnremoterepo(make_ui('db'), url).capabilities
elif repo_type == 'git':
#TODO: write a git url validator
'clone_uri': _(u'invalid clone url'),
'invalid_clone_uri': _(u'Invalid clone url, provide a '
'valid clone http\s url')
'valid clone http(s)/svn+http(s) url')
repo_type = value.get('repo_type')
url = value.get('clone_uri')
if not url:
elif url.startswith('https') or url.startswith('http'):
_type = 'https' if url.startswith('https') else 'http'
url_handler(repo_type, url, _type, make_ui('db'))
url_handler(repo_type, url, make_ui('db'))
log.exception('Url validation failed')
msg = M(self, 'clone_uri')
error_dict=dict(clone_uri=msg)
msg = M(self, 'invalid_clone_uri', state)
def ValidForkType(old_data={}):
'invalid_fork_type': _(u'Fork have to be the same type as parent')
if old_data['repo_type'] != value:
msg = M(self, 'invalid_fork_type', state)
error_dict=dict(repo_type=msg)
def ValidPerms(type_='repo'):
if type_ == 'group':
EMPTY_PERM = 'group.none'
elif type_ == 'repo':
EMPTY_PERM = 'repository.none'
'perm_new_member_name':
_(u'This username or users group name is not valid')
def to_python(self, value, state):
perms_update = []
perms_new = []
# build a list of permission to update and new permission to create
for k, v in value.items():
# means new added member to permissions
if k.startswith('perm_new_member'):
new_perm = value.get('perm_new_member', False)
new_member = value.get('perm_new_member_name', False)
new_type = value.get('perm_new_member_type')
if new_member and new_perm:
if (new_member, new_perm, new_type) not in perms_new:
perms_new.append((new_member, new_perm, new_type))
elif k.startswith('u_perm_') or k.startswith('g_perm_'):
member = k[7:]
t = {'u': 'user',
'g': 'users_group'
}[k[0]]
if member == 'default':
if value.get('private'):
# set none for default when updating to
# private repo
v = EMPTY_PERM
perms_update.append((member, v, t))
value['perms_updates'] = perms_update
value['perms_new'] = perms_new
# update permissions
for k, v, t in perms_new:
if t is 'user':
self.user_db = User.query()\
.filter(User.active == True)\
.filter(User.username == k).one()
if t is 'users_group':
self.user_db = UsersGroup.query()\
.filter(UsersGroup.users_group_active == True)\
.filter(UsersGroup.users_group_name == k).one()
log.exception('Updated permission failed')
msg = M(self, 'perm_new_member_type', state)
error_dict=dict(perm_new_member_name=msg)
def ValidSettings():
# settings form can't edit user
if 'user' in value:
del value['user']
def ValidPath():
'invalid_path': _(u'This is not a valid path')
if not os.path.isdir(value):
msg = M(self, 'invalid_path', state)
error_dict=dict(paths_root_path=msg)
def UniqSystemEmail(old_data={}):
'email_taken': _(u'This e-mail address is already taken')
return value.lower()
if (old_data.get('email') or '').lower() != value:
user = User.get_by_email(value, case_insensitive=True)
if user:
msg = M(self, 'email_taken', state)
error_dict=dict(email=msg)
def ValidSystemEmail():
'non_existing_email': _(u'e-mail "%(email)s" does not exist.')
if user is None:
msg = M(self, 'non_existing_email', state, email=value)
def LdapLibValidator():
import ldap
ldap # pyflakes silence !
except ImportError:
raise LdapImportError()
def AttrLoginValidator():
'invalid_cn':
_(u'The LDAP Login attribute of the CN must be specified - '
'this is the name of the attribute that is equivalent '
'to "username"')
if not value or not isinstance(value, (str, unicode)):
msg = M(self, 'invalid_cn', state)
error_dict=dict(ldap_attr_login=msg)
Status change: