Permalink
Browse files

init of projectsmanager for trac

  • Loading branch information...
0 parents commit 8a0406160ccb706df110532ce4fe693bb1fec2fa @zjj committed Oct 25, 2010
@@ -0,0 +1,13 @@
+sync the database before you run 'python setup.py install'
+modify the env_path(line 10) to the trac environment that you want to use this plugin in the database_sync.py
+modify the username who you want to add the actions to in the particular Environment the env_path points to in the database_sync.py
+modify the 'TRAC_DIR','INHERIT_FILE'and 'BASE_URL' (they are in the first few linew) in the projectsmanage.py to the path that corresponding to your own server
+add next three rows to trac.ini (modify the inherit_file and base_url to the right values corresponding to your projects
+
+[projectsmanager]
+inherit_file=/var/....g_trac.ini
+base_url=http://172.16.2.177:8000
+
+
+
+
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+from trac.env import Environment
+import os
+# modify the env_path to the trac environment that you want to install this plugin to
+#e.g. env_path='/var/www/code/trac/projects/ddd'
+env_path='/var/www/trac/projects/master'
+env=Environment(env_path)
+cnx=env.get_db_cnx()
+cur=cnx.cursor()
+#create a table named 'project' to manage the trac projects that the users may apply
+create_project_table='''
+CREATE TABLE project(
+ id integer PRIMARY KEY,
+ owner text,
+ email text,
+ proj_name text,
+ proj_full_name text,
+ description text,
+ apply_time integer,
+ exam_time integer,
+ stat integer
+ );
+'''
+create_project_change_table='''
+CREATE TABLE project_change(
+ id integer PRIMARY KEY,
+ who text,
+ change text,
+ time integer
+ );
+'''
+# add PROJECT_CREATE PROJECT_APPROVE PROJECT_REJECT PROJECT_DELETE to a particular username ,
+# generally we add them to one who has the TRAC_ADMIN action,please modify the username here.
+#e.g. username='admin'
+
+#username='superman'
+#actions=['PROJECT_CREATE','PROJECT_APPROVE','PROJECT_REJECT','PROJECT_DELETE']
+print '**********************************************************'
+print " START SYNCHRONIZING DATABASE \n\n"
+try:
+ cur.execute(create_project_table)
+ print create_project_table,'\nDONE'
+ cur.execute(create_project_change_table)
+ print create_project_change_table,'\nDONE'
+except:
+ pass
+
+
+#for action in actions:
+# add_actions="insert into permission values ('%s','%s');"%(username,action)
+# try:
+# cur.execute(add_actions)
+# print add_actions, '\nDONE'
+# except:
+# pass
+cur.close()
+cnx.commit()
+cnx.close()
+print "SYNCHRONIZE DATABASE DONE!"
+print '**********************************************************'
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -0,0 +1,2 @@
+from projectsmanager import *
+
Oops, something went wrong.

0 comments on commit 8a04061

Please sign in to comment.