티스토리 뷰

728x90

"Trac 수정을 위한 개발 환경 준비하기"는 대표적인 협업 개발 도구인 Trac(http://trac.edgewall.org/)을 설치하고 사용하는 것을 넘어서 직접 코드를 수정하고자 하는 사람에게 필요한 과정입니다.

 

개발 환경이란 실제 사용자들이 사용중인 시스템과는 별개의 시스템으로 개발 과정중에 발생할 수 있는 다양한 오류 가능성과 장애로 부터 자유로울 수 있는 시스템을 의미합니다.  Trac은 자체적인 서비스 대몬을(tracd) 소유하고 있으므로 Trac 코드 수정을 위한 시스템을 실제 시스템과 동일하게 구축할 필요는 없습니다. 아래의 개발 환경은 윈도우 시스템을 기준으로 했으며 텍스트 편집기로 소스 코드를 수정한다는 가정하에 진행했습니다.



■ 파이썬 환경 설치


"파이썬(Python) 실행 환경 준비하기" 포스팅을 참조해서 파이썬 환경을 준비합니다. 현재 3.7.2 버전과 2.7.15버전을 동시에 배포하고 있는데 연관 라이브러리등의 문제가 있으므로 2.7 버전대의 최신버전을 설치합니다. 다운로드 주소는 아래와 같습니다.

https://www.python.org/ftp/python/2.7.15/python-2.7.15.msi

 

아래 화면은 명령행으로 파이썬의 버전을 확인하는 화면입니다. python.exe -V로 버전을 확인할 수 있습니다.

 




■ 서브버전 환경 설치


Trac과 가장 잘 맞는 형상 관리 도구이기도 하지만 Trac 개발을 코드를 받는 과정과 추후 나름의 개발 내역을 형상 관리하기 위해서도 필요한 도구로 예제에서는 TortoiseSVN을 사용합니다. 다운로드 및 설치는 https://tortoisesvn.net/downloads.html 를 참조합니다.

 

정상적으로 설치했으면 탐색기의 팝업 메뉴에 다음 그림과 같이 SVN Checkout과 TortoiseSVN 메뉴를 확인할 수 있습니다.





■ Trac 소스 체크아웃 및 설치


https://svn.edgewall.org/repos/trac/tags/trac-1.2 를 리포지토리 주소로 하여 소스 코드를 체크아웃 받습니다.



소스 체크 아웃이 끝나면 Trac 폴더로 이동하여 "python setup.py develop"로 설치를 진행 합니다.


C:\tmp\trac12>\Python27\python.exe setup.py develop
Genshi is needed by Trac setup, pre-installing
running develop
running egg_info
writing requirements to Trac.egg-info\requires.txt
writing Trac.egg-info\PKG-INFO
writing top-level names to Trac.egg-info\top_level.txt
writing dependency_links to Trac.egg-info\dependency_links.txt
writing entry points to Trac.egg-info\entry_points.txt
reading manifest file 'Trac.egg-info\SOURCES.txt'
writing manifest file 'Trac.egg-info\SOURCES.txt'
running build_ext
Creating c:\python27\lib\site-packages\Trac.egg-link (link to .)
Adding Trac 1.2 to easy-install.pth file
Installing trac-admin-script.py script to C:\Python27\Scripts
Installing trac-admin.exe script to C:\Python27\Scripts
Installing trac-admin.exe.manifest script to C:\Python27\Scripts
Installing tracd-script.py script to C:\Python27\Scripts
Installing tracd.exe script to C:\Python27\Scripts
Installing tracd.exe.manifest script to C:\Python27\Scripts

Installed c:\tmp\trac12
Processing dependencies for Trac==1.2
Searching for genshi==0.7.1
Best match: genshi 0.7.1
Processing genshi-0.7.1-py2.7-win32.egg
Adding genshi 0.7.1 to easy-install.pth file

Using c:\tmp\trac12\.eggs\genshi-0.7.1-py2.7-win32.egg
Searching for setuptools==39.0.1
Best match: setuptools 39.0.1
Adding setuptools 39.0.1 to easy-install.pth file
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install.exe.manifest script to C:\Python27\Scripts
Installing easy_install-3.6-script.py script to C:\Python27\Scripts
Installing easy_install-3.6.exe script to C:\Python27\Scripts
Installing easy_install-3.6.exe.manifest script to C:\Python27\Scripts

Using c:\python27\lib\site-packages
Finished processing dependencies for Trac==1.2


Trac 설치 과정에서 필요한 Genshi 패키지와 setuptools를 맞춤 버전을 찾아서 설치하는 것을 확인할 수 있습니다.



■ 테스트 프로젝트 생성 및 가동 시험


위의 Trac의 개발 버전 설치 과정을 보면 알 수 있듯이 trac-admin, tracd 등 Trac을 사용하는데 필수적인 도구들은 파이썬 환경의 Scripts 폴더에 저장되므로 테스트 프로젝트 생성 등의 명령을 사용하려면 수행 경로등 파이썬 환경을 감안해서 사용합니다.

 

프로젝트 파일들을 저장할 폴더로 이동하여 "trac-admin devtest initenv"로 Trac 프로젝트를 생성합니다. 프롬프트로 프로젝트 명을 요구하면 적절하게 입력하고 사용 DB는 기본 SQLite를 그대로 사용합니다.(그냥 엔터)


C:\>cd \Python27

C:\Python27>Scripts\trac-admin.exe devtest initenv
Creating a new Trac environment at C:\Python27\devtest

Trac will first ask a few questions about your environment
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> devtest

 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an existing MySQL or
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]>

Creating and Initializing Project
 Installing default wiki pages
  CamelCase imported from c:\tmp\trac12\trac\wiki\default-pages\CamelCase
  InterMapTxt imported from c:\tmp\trac12\trac\wiki\default-pages\InterMapTxt
  InterTrac imported from c:\tmp\trac12\trac\wiki\default-pages\InterTrac
  InterWiki imported from c:\tmp\trac12\trac\wiki\default-pages\InterWiki
  PageTemplates imported from c:\tmp\trac12\trac\wiki\default-pages\PageTemplates
  RecentChanges imported from c:\tmp\trac12\trac\wiki\default-pages\RecentChanges
  SandBox imported from c:\tmp\trac12\trac\wiki\default-pages\SandBox
  TicketQuery imported from c:\tmp\trac12\trac\wiki\default-pages\TicketQuery
  TitleIndex imported from c:\tmp\trac12\trac\wiki\default-pages\TitleIndex
  TracAccessibility imported from c:\tmp\trac12\trac\wiki\default-pages\TracAccessibility
  TracAdmin imported from c:\tmp\trac12\trac\wiki\default-pages\TracAdmin
  TracBackup imported from c:\tmp\trac12\trac\wiki\default-pages\TracBackup
  TracBatchModify imported from c:\tmp\trac12\trac\wiki\default-pages\TracBatchModify
  TracBrowser imported from c:\tmp\trac12\trac\wiki\default-pages\TracBrowser
  TracCgi imported from c:\tmp\trac12\trac\wiki\default-pages\TracCgi
  TracChangeLog imported from c:\tmp\trac12\trac\wiki\default-pages\TracChangeLog
  TracChangeset imported from c:\tmp\trac12\trac\wiki\default-pages\TracChangeset
  TracEnvironment imported from c:\tmp\trac12\trac\wiki\default-pages\TracEnvironment
  TracFastCgi imported from c:\tmp\trac12\trac\wiki\default-pages\TracFastCgi
  TracFineGrainedPermissions imported from c:\tmp\trac12\trac\wiki\default-pages\TracFineGrainedPermissions
  TracGuide imported from c:\tmp\trac12\trac\wiki\default-pages\TracGuide
  TracImport imported from c:\tmp\trac12\trac\wiki\default-pages\TracImport
  TracIni imported from c:\tmp\trac12\trac\wiki\default-pages\TracIni
  TracInstall imported from c:\tmp\trac12\trac\wiki\default-pages\TracInstall
  TracInterfaceCustomization imported from c:\tmp\trac12\trac\wiki\default-pages\TracInterfaceCustomization
  TracLinks imported from c:\tmp\trac12\trac\wiki\default-pages\TracLinks
  TracLogging imported from c:\tmp\trac12\trac\wiki\default-pages\TracLogging
  TracModPython imported from c:\tmp\trac12\trac\wiki\default-pages\TracModPython
  TracModWSGI imported from c:\tmp\trac12\trac\wiki\default-pages\TracModWSGI
  TracNavigation imported from c:\tmp\trac12\trac\wiki\default-pages\TracNavigation
  TracNotification imported from c:\tmp\trac12\trac\wiki\default-pages\TracNotification
  TracPermissions imported from c:\tmp\trac12\trac\wiki\default-pages\TracPermissions
  TracPlugins imported from c:\tmp\trac12\trac\wiki\default-pages\TracPlugins
  TracQuery imported from c:\tmp\trac12\trac\wiki\default-pages\TracQuery
  TracReports imported from c:\tmp\trac12\trac\wiki\default-pages\TracReports
  TracRepositoryAdmin imported from c:\tmp\trac12\trac\wiki\default-pages\TracRepositoryAdmin
  TracRevisionLog imported from c:\tmp\trac12\trac\wiki\default-pages\TracRevisionLog
  TracRoadmap imported from c:\tmp\trac12\trac\wiki\default-pages\TracRoadmap
  TracRss imported from c:\tmp\trac12\trac\wiki\default-pages\TracRss
  TracSearch imported from c:\tmp\trac12\trac\wiki\default-pages\TracSearch
  TracStandalone imported from c:\tmp\trac12\trac\wiki\default-pages\TracStandalone
  TracSupport imported from c:\tmp\trac12\trac\wiki\default-pages\TracSupport
  TracSyntaxColoring imported from c:\tmp\trac12\trac\wiki\default-pages\TracSyntaxColoring
  TracTickets imported from c:\tmp\trac12\trac\wiki\default-pages\TracTickets
  TracTicketsCustomFields imported from c:\tmp\trac12\trac\wiki\default-pages\TracTicketsCustomFields
  TracTimeline imported from c:\tmp\trac12\trac\wiki\default-pages\TracTimeline
  TracUnicode imported from c:\tmp\trac12\trac\wiki\default-pages\TracUnicode
  TracUpgrade imported from c:\tmp\trac12\trac\wiki\default-pages\TracUpgrade
  TracWiki imported from c:\tmp\trac12\trac\wiki\default-pages\TracWiki
  TracWorkflow imported from c:\tmp\trac12\trac\wiki\default-pages\TracWorkflow
  WikiDeletePage imported from c:\tmp\trac12\trac\wiki\default-pages\WikiDeletePage
  WikiFormatting imported from c:\tmp\trac12\trac\wiki\default-pages\WikiFormatting
  WikiHtml imported from c:\tmp\trac12\trac\wiki\default-pages\WikiHtml
  WikiMacros imported from c:\tmp\trac12\trac\wiki\default-pages\WikiMacros
  WikiNewPage imported from c:\tmp\trac12\trac\wiki\default-pages\WikiNewPage
  WikiPageNames imported from c:\tmp\trac12\trac\wiki\default-pages\WikiPageNames
  WikiProcessors imported from c:\tmp\trac12\trac\wiki\default-pages\WikiProcessors
  WikiRestructuredText imported from c:\tmp\trac12\trac\wiki\default-pages\WikiRestructuredText
  WikiRestructuredTextLinks imported from c:\tmp\trac12\trac\wiki\default-pages\WikiRestructuredTextLinks
  WikiStart imported from c:\tmp\trac12\trac\wiki\default-pages\WikiStart

---------------------------------------------------------------------
Project environment for 'devtest' created.

You may now configure the environment by editing the file:

  C:\Python27\devtest\conf\trac.ini

If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

  tracd --port 8000 C:\Python27\devtest

Then point your browser to http://localhost:8000/devtest.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project
website:

  http://trac.edgewall.org/

Congratulations!


위의 프로젝트 생성 과정을 살펴보면 현재 디렉토리에 지정한 프로젝트 이름으로 폴더를 생성하는 것을 확인할 수 있으며 생성 작업 끝에 "tracd --port 8000 C:\Python27\devtest"로 내장된 자체 서버를 가동시킬 수 있음을 확인 할 수 있습니다. 프로젝트 수행 환경을 설정하는 환경 파일의 위치인 "C:\Python27\devtest\conf\trac.ini"를 확인할 수 있고 웹브라우저에서 "http://localhost:8000/devtest"로 입력하면 결과를 확인할 수 있음을 안내하고 있습니다.



위의 그림은 tracd를 가동시킨 화면입니다. tracd 서버를 가동시키면 보안 경고창이 나올 수 있는데 이때 차단 해제하면 정상적으로 서버를 가동시킬 수 있습니다.

 


웹브라우저에서 "http://127.0.0.1:8000/devtest" 주소를 입력하면 Trac 페이지에 들어갈 수 있습니다.




■ 소스 코드 수정과 적용 확인


위에서 웹 브라우저로 테스트 프로젝트가 정상적으로 보여지는 것을 확인했으면 이제는 실제 코드를 수정하여 해당 수정 내용이 시스템에 반영되는지 확인하면 Trac 수정을 위한 기초적인 개발 준비는 끝납니다. 위의 그림에 나오는 테스트 프로젝트의 첫 페이지는 위키 페이지로 관련 코드는 아래 그림과 같이 서브버전으로 체크아웃 받은 폴더의 trac/wiki폴더에 위치하고 있습니다. 설치과정에서 tracd나 trac-admin등은 파이썬 환경으로 복사되었지만 소스코드는 체크아웃 받은 폴더를 기준으로 작업합니다.




간단한 수정 테스트를 위해서 위키 관련 코드 중에 web_ui.py를 열고 _wiki_ctxtnav함수를 찾아 아래와 같이 페이지 상단에 네비게이션중에 "Start Page"링크를 "Start Page!!!"로 수정하고 저장합니다.


	def _wiki_ctxtnav(self, req, page):
        """Add the normal wiki ctxtnav entries."""
        add_ctxtnav(req, _('Start Page!!!'), req.href.wiki('WikiStart'))
        add_ctxtnav(req, _('Index'), req.href.wiki('TitleIndex'))
        if page.exists:
            add_ctxtnav(req, _('History'), req.href.wiki(page.name,
                                                         action='history'))


소스 코드를 수정하고 나면 tracd를 재가동 시키고 웹브라우저에서 페이지를 새로고침 합니다. tracd를 -r 옵션으로 가동시키면 소스 코드 수정을 인식하여 자동으로 재가동하는데 이 옵션이 잘 적용되지 않으면 그냥 tracd를 재가동시키면 됩니다.



위의 화면은 코드 수정 내용을 반영한 결과 화면입니다.



■ 인증 파일 생성과 가동


Trac 단순 화면은 위의 설명과 같이 볼수 있지만 티켓이나 관리자 화면등은 반드시 로그인되어야 하므로 인증 파일 생성이 필요합니다. Trac 코드가 있는 디렉토리 아래 contrib 폴더에 htdigest.py라는 도구를 활용해서 인증 파일을 생성하고 admin 관리자의 비밀번호를 아래와 같이 생성합니다. 


수행할 명령은 "python htdigest.py -c tracpasswd.txt mytrac admin"와 같은데 "인증용파일명 realm 사용자아이디"의 형식 입니다.



새롭게 추가할 admin 아이디의 비밀번호를 입력하면 현재 폴더에 tracpasswd.txt 파일을 생성하면서 인증 파일을 생성합니다.



위의 그림은 인증 파일을 적용하고 적용 포트를 80으로 하여 웹브라우저에서 별도의 포트를 지정하지 않도록 서비스를 가동 시킨 것입니다. --auth= 다음에 기술하는 것은 "프로젝트명,인증파일명,realm" 입니다.




웹브라우저에서 별도의 포트를 지정하지 않도록 띄워서 로그인하여 새로운 티켓을 발행하는 화면입니다. 위의 화면은 일반 사용자 권한으로 로그인 했을때의 화면으로 관리자 화면등이 나오지 않았는데 새롭게 추가한 admin 아이디에 관리자 권한을 부여하려면 "trac-admin \Python27\devtest permission add admin TRAC_ADMIN"과 같이 수행하면 됩니다. 




728x90
댓글
최근에 올라온 글
최근에 달린 댓글
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함