Skip to main content

IPv6-IPv4 TCP Relay & PortProxy

· One min read

在看 ブロードバンドルータ (CG-BARPRO6) による OCN IPv6 接続 這篇文章時, 發現回覆中提到很可惜沒支援 "v6-v4 TCP Relay" 這功能.

IPv6-IPv4 TCP Relay 到底是什麼呢?

上網查了一查,原來就是一種 BIS (Bump In Stack) 的應用,讓 IPv4 Only 的程式可以透過 Port Mapping 來存取 IPv6 網路.

例如回覆中提到一台僅支援 IPv4 的網路電視機器,因為區網內使用私有地址的關係,需要在外部建一台 Virtual Server 才能在各地存取網路電視這資源. 如果 Router 能支援 "IPv6-IPv4 TCP Relay", 我們就能在外部使用 IPv6 位址存取網路電視了!

想起來就很讚,做起來.......:-D

參考: 介面 Portproxy 的 Netsh 命令

Assimilate Django Template to TurboGears

· 2 min read

Lots of people use Django template for Pyhton Web Framework(As Django project shares).

And if we want to make people feel comfortable to try TurboGears (and then migrate to tg hopefully), first thing we can do is making django template system available on TurboGears.

Its easy because many template plugins (and their source codes) are available for TurboGears, I use a couple hours to read the template plugins doc and make the TurboDjango template plugin.

You can try the django template in minutes. Here is the step by step guide:

Install By SetupTools

$ easy_install TurboDjango

How to Make it just Work?

Step 1. Quickstart

Use tg-admin tool to create a project

$ tg-admin quickstart tgdj

The project name is "tgdj"

Step 2. Edit Controller

Edit tgdj/tgdj/controller.py, add following method in "Root" class.

@expose(template = "django:tgdj.templates.djpage") def page(self): return dict(name="TurboGears") "djpage" is django template name

Step 3. Edit Template

Edit tgdj/tgdj/templates/djpage.html

[h1]Hello, {{name}}[/h1]

The template has "html" file suffix

Step 4. Check Result

In tgdj, start develop server by typing

$ start-tgdj

Then surf http://localhost:8080/page, you'll see

The Release is available here.

To Django Users: You can migrate your database with SQLAlchemy's SqlSoup

TurboGears 中使用 Django 模板

· One min read

利用 TurboDjango Template Plugin, 可以在 TurboGears, Buffet, 或 CherryPy 裡如此這般調用 Django 模板:

在 controller.py 裡

{{{
@expose(template = "django:dem.templates.djpage")
def page(self):
return dict(name="TurboGears")

<div id="qhide_141663" style="display: block;" class="qt">}}}

用 "template" 參數指定樣板時加一個 "django:" 前綴, 或是在設定檔 app.cfg 中將預設的 tg.defaultview = "kid" 改成 tg.defaultview = "django" 就可以在全站使用 django 模板.

djpage 是模板名稱,return dict 後面給的參數群是要傳給模板的參數.

在 djpage.html 裡


[h1]Hello, {{name}}[/h1]
<div id="qhide_141664" style="display: block;" class="qt">}}}

djpage 是模板名稱,html 是檔名

網頁 http://localhost:8080/page 的輸出結果是

"

"

Eclipse Configuration for TurboGears

· 2 min read

Continue to my previous article, here is a configuration using eclipse external tools to start web server without open start-proj.py

Here is a list of the current functionality:

External Tools:

  • Start Server

  • Start ToolboxAccessibility:

  • Auto Completion Configure Eclipse to Launch developer server

  • Select** Run -> External Tools -> External Tools **

  • Select** "Program" from the configuration** tree* Select New to create a new program* Enter “Start Server” as the name* Enter C:\Python24\pythonw.exe for the Location* For the Working Directory, use ${project_loc}

  • Enter start-${project_name}.py for the Arguments

  • Select the refresh tab and check Refresh Resources Upon Completion

  • Select the Common tab * Find the section for Display in Favorites Menu

    • Check **External Tools option *** Select Apply Configure Eclipse to Launch ToolBox
  • Select** Run -> External Tools -> External Tools **

  • Select** "Program" from the configuration** tree* Select New to create a new program* Enter “Start ToolBox” as the name* Enter C:\Python24\Scripts\tg-admin.exe for the Location* For the Working Directory, use ${project_loc}

  • Enter toolbox** **for the Arguments

  • Select the Common tab * Find the section for Display in Favorites Menu

    • Check **External Tools option *** Select Apply

Auto-completion

  • Select your project in Navigator panel
  • Select Properties on Right click menu.
  • Select** pyDev - PYTHONPATH Select Add source folder to add project path in Project Source Folder. **it will bring project code-completion and code-analysis.
  • Select ** Add source folder **to add turbogears path in External Source Folder.

it will bring turbogears code-completion PS: I get idea from the rails article, but for mine, you'd have eclipse & pydev installed, I recommand you try EasyEclipse for Python.