= Trac 플러그인 =
[[TracGuideToc]]

버전 0.9부터, Trac은 내장된 기능을 확장할 수 있는 플러그인을 지원합니다. 플러그인의 기능은 [http://projects.edgewall.com/trac/wiki/TracDev/ComponentArchitecture 콤포넌트 구조]에 기반합니다.

== 요구사항 ==

To use plugins in Trac, you need to have [http://peak.telecommunity.com/DevCenter/setuptools setuptools] (version 0.6) installed.

`setuptools`을 설치하기 위해서는, [http://peak.telecommunity.com/dist/ez_setup.py ez_setup.py] 부트스트랩 모듈을 다운로드 받아서, 다음과 같이 실행하십시오.:
{{{
$ python ez_setup.py
}}}

만약 `ez_setup.py` 스트립트가 setuptools을 설치하지 못한다면, [http://www.python.org/pypi/setuptools PyPI]로부터 직접 다운로드 받아서, 수동으로 설치할 수 있습니다.

== Trac 플러그인 설치하기 ==

=== 하나의 프로젝트에 대해서 ===

플러그인들은 [http://peak.telecommunity.com/DevCenter/PythonEggs Python eggs]로 패키지되어있습니다. 이것은 파일 확장자가 `.egg`인 zip 압축파일을 의미합니다. 만약 소스 형태의 플러그인을 다운받았다면, `.egg` 파일을 만들기 위해서 다음과 같이 실행할 수 있습니다.:
{{{
$ python setup.py bdist_egg
}}}

플러그인 파일을 가지고 있다면, 프로젝트의 [wiki:TracEnvironment Trac 저장소]의 `plugins` 디렉토리에 복사하셔야 합니다. 또한 웹서버에서 플러그인을 읽을 수 있는 권한을 가지고 있는지 확인하십시오.

=== 모든 프로젝트에 대해서 ===

모든 프로젝트에서 사용하기를 원하는 플러그인들([http://projects.edgewall.com/trac/wiki/WebAdmin WebAdmin] 플러그인같은)은 다음과 같이 전체적으로 설치될 수 있습니다.:
{{{
$ python setup.py install
}}}

다른 방법으로는 `.egg` 파일을 Python의 `site-packages` 디렉토리에 복사해도 됩니다.

Unlike plugins installed per-environment, you'll have to explicitly enable globally installed plugins via [wiki:TracIni trac.ini]. This is done in the `[components]` section of the configuration file, for example:
{{{
[components]
webadmin.* = enabled
}}}

The name of the option is the Python package of the plugin. This should be specified in the documentation of the Plugin, but can also be easily find out by looking at the source (look for a top-level directory that contains a file named `__init__.py`.)

== 플러그인 캐시 설정하기 ==

일부 플러그인들은 파일시스템상에 플러그인의 파일들이 실제 파일로 존재해야하기 때문에 실행시(`pkg_resources`)에 Python eggs에 의해서 압축이 풀어져야 합니다. 기본적으로 압축이 풀리는 디렉토리는 현재 사용자의 홈디렉토리입니다. 이것은 문제가 있을 수도, 없을 수도 있습니다. `PYTHON_EGG_CACHE` 환경변수를 사용해서 기본 위치를 변경할 수 있습니다.

아파치 설정에서 이렇게 하기위해서는, 다음과 같이 `SetEnv` 지시자를 사용하십시오.:
{{{
SetEnv PYTHON_EGG_CACHE /path/to/dir
}}}

[wiki:TracCgi CGI]나 [wiki:TracModPython mod_python]을 사용하는 경우에 이것을 정상적으로 동작할 것입니다. 이 지시자를 [wiki:TracEnvironment Trac 저장소]의 경로를 설정한 다음에 넣으십시오. 즉, 같은 `<Location>` 블럭안에 넣으십시오.

예를 들면 (CGI의 경우):
{{{
 <Location /trac>
   SetEnv TRAC_ENV /path/to/projenv
   SetEnv PYTHON_EGG_CACHE /path/to/dir
 </Location>
}}}

혹은 (mod_python의 경우):
{{{
 <Location /trac>
   SetHandler mod_python
   ...
   SetEnv PYTHON_EGG_CACHE /path/to/dir
 </Location>
}}}

[wiki:TracFastCgi FastCGI]에 대해서는, `-initial-env` 옵션이나 환경변수를 설정하기 위해 사용중인 웹서버에서 제공되는 것이 필요할 것입니다.

----
참고 : TracGuide, [http://projects.edgewall.com/trac/wiki/PluginList plugin list], [http://projects.edgewall.com/trac/wiki/TracDev/ComponentArchitecture component architecture]
