弄了近3天(这个周末是totally进去咯),总算把viewvc修改成只读权限(这里说的只读权限是指svnauthz中配置为只读权限)的用户只能查看log了 O(∩_∩)O哈哈~
太累了,先发贴占个位子,等几天把代码及修改的详细地方贴出来~~
O(∩_∩)O哈哈~
主要是在viewvc.py中增加两个viewvc现成的函数_process_access_section(self, cp, section)
_userspec_matches_user(self, userspec):
然后在class Request:
def __init__(self, server, cfg):
函数中,在获得了USERNAME后面,加上下面的语句:
(说起这几句话简单,就是把diff,annotate,markup 三种view从cfg中去掉,不晓得我看了好久的代码才找到是该在这个位置里添加!沁透了我的汗水啊~~~~兄弟们,给我顶~~~↖(^ω^)↗):
#Brant
logging.basicConfig(level=logging.DEBUG,
format=’%(asctime)s %(levelname)s %(message)s’,
filename=’D:/Viewvc.Request.log’,
filemode=’w’)
logging.debug(‘A debug message1’)
cp1 = ConfigParser()
cp1.read(self.cfg.conf_path) # Read viewvc.conf
svnauthzfile = cp1.get(“authz-svnauthz”, “authzfile”) # get svnauthzfile frmo viewvc.conf
cp = ConfigParser()
cp.read(svnauthzfile) # Read svnauthzfile
root_sections = []
no_diff_annonate_markup_view = 0
logging.debug(‘below:cp.sections’)
logging.debug(cp.sections())
for section in cp.sections():
logging.debug(‘A debug message5’)
# Skip the “groups” section — we handled that already.
if section == ‘groups’:
continue
if section == ‘aliases’:
continue
no_diff_annonate_markup_view = _process_access_section(self, cp, section)
logging.debug(‘after1 cp.sections[%s] haha:%d’, section, no_diff_annonate_markup_view)
logging.debug(‘ooo view_result:%d’, no_diff_annonate_markup_view)
logging.debug(self.cfg.options.allowed_views)
if no_diff_annonate_markup_view == 1:
if ‘diff’ in self.cfg.options.allowed_views:
self.cfg.options.allowed_views.remove(‘diff’);
if ‘markup’ in self.cfg.options.allowed_views:
self.cfg.options.allowed_views.remove(‘markup’);
if ‘annotate’ in self.cfg.options.allowed_views:
self.cfg.options.allowed_views.remove(‘annotate’);
if ‘diff’ in cfg.options.allowed_views:
cfg.options.allowed_views.remove(‘diff’);
if ‘markup’ in cfg.options.allowed_views:
cfg.options.allowed_views.remove(‘markup’);
if ‘annotate’ in cfg.options.allowed_views:
cfg.options.allowed_views.remove(‘annotate’);
其他的工作就是修改下viewcv的模板。等几天再写吧,O(∩_∩)O哈哈~
PS几句:
偶从来没想过会用python这个后起新秀,更别说学习它了!更别说修改一个用它写的开源工具了!
可是这周末没想到鬼使神差地硬把Viewvc按照我的需求给改了!
我都觉得我疯了~~
不过看到自己成果后,还是爽翻了O(∩_∩)O哈哈~