博客统计信息

51cto推荐博客
用户名:xkdcc
文章数:114
评论数:55
访问量:108955
无忧币:994
博客积分:2066
博客等级:6
注册日期:2008-06-26

修改Viewvc代码使只读权限的用户只能查看log
2009-10-18 14:57:07
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://brantc.blog.51cto.com/410705/213780

弄了近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哈哈~

本文出自 “BrantC的博客” 博客,请务必保留此出处http://brantc.blog.51cto.com/410705/213780

分享至
更多
一键收藏,随时查看,分享好友!
0人
了这篇文章
类别:Dev && SCM技术圈()┆阅读()┆评论() ┆ 推送到技术圈返回首页

文章评论

 
2009-10-21 17:41:00
你很有才,鉴定完毕。

 

发表评论            

【技术门诊】专家解析:软考重点难点及应试技巧
昵  称:
登录  快速注册
验证码:

请点击后输入验证码博客过2级,无需填写验证码

内  容: