equal
deleted
inserted
replaced
25 from warnings import warn |
25 from warnings import warn |
26 |
26 |
27 from logilab.common.decorators import cached |
27 from logilab.common.decorators import cached |
28 from logilab.common.deprecation import deprecated |
28 from logilab.common.deprecation import deprecated |
29 |
29 |
|
30 from cubicweb import ConfigurationError |
30 from cubicweb.toolsutils import read_config |
31 from cubicweb.toolsutils import read_config |
31 from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options, merge_options |
32 from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options, merge_options |
32 |
33 |
33 |
34 |
34 register_persistent_options( ( |
35 register_persistent_options( ( |
237 |
238 |
238 def vc_config(self): |
239 def vc_config(self): |
239 return self.repository().get_versions() |
240 return self.repository().get_versions() |
240 |
241 |
241 def anonymous_user(self): |
242 def anonymous_user(self): |
242 """return a login and password to use for anonymous users. None |
243 """return a login and password to use for anonymous users. |
243 may be returned for both if anonymous connections are not allowed |
244 |
|
245 None may be returned for both if anonymous connection is not |
|
246 allowed or if an empty login is used in configuration |
244 """ |
247 """ |
245 try: |
248 try: |
246 user = self['anonymous-user'] |
249 user = self['anonymous-user'] or None |
247 passwd = self['anonymous-password'] |
250 passwd = self['anonymous-password'] |
|
251 if user: |
|
252 user = unicode(user) |
248 except KeyError: |
253 except KeyError: |
249 user, passwd = None, None |
254 user, passwd = None, None |
250 if user is not None: |
255 except UnicodeDecodeError: |
251 user = unicode(user) |
256 raise ConfigurationError("anonymous information should only contains ascii") |
252 return user, passwd |
257 return user, passwd |
253 |
258 |
254 def locate_resource(self, rid): |
259 def locate_resource(self, rid): |
255 """return the (directory, filename) where the given resource |
260 """return the (directory, filename) where the given resource |
256 may be found |
261 may be found |