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( ( |
231 |
232 |
232 def vc_config(self): |
233 def vc_config(self): |
233 return self.repository().get_versions() |
234 return self.repository().get_versions() |
234 |
235 |
235 def anonymous_user(self): |
236 def anonymous_user(self): |
236 """return a login and password to use for anonymous users. None |
237 """return a login and password to use for anonymous users. |
237 may be returned for both if anonymous connections are not allowed |
238 |
|
239 None may be returned for both if anonymous connection is not |
|
240 allowed or if an empty login is used in configuration |
238 """ |
241 """ |
239 try: |
242 try: |
240 user = self['anonymous-user'] |
243 user = self['anonymous-user'] or None |
241 passwd = self['anonymous-password'] |
244 passwd = self['anonymous-password'] |
|
245 if user: |
|
246 user = unicode(user) |
242 except KeyError: |
247 except KeyError: |
243 user, passwd = None, None |
248 user, passwd = None, None |
244 if user is not None: |
249 except UnicodeDecodeError: |
245 user = unicode(user) |
250 raise ConfigurationError("anonymous information should only contains ascii") |
246 return user, passwd |
251 return user, passwd |
247 |
252 |
248 def locate_resource(self, rid): |
253 def locate_resource(self, rid): |
249 """return the (directory, filename) where the given resource |
254 """return the (directory, filename) where the given resource |
250 may be found |
255 may be found |