2010年5月30日 星期日

Django - Template

Template的用法備註
http://djangobook.py3k.cn/2.0/chapter04/
  • 可用的變數範圍
    • 字典
    • 屬性
    • 方法 - 必須是無參數的方法
    • 列表類型 - List, tuple等
  • "方法"的使用,需特別注意
    • 方法若出異常,則錯誤訊息會往上傳。若該異常有silent_variable_failure的屬性,且設定為true,則不會將訊息往上傳出。
    • 方法需注意使用。ex mytest.delete() 會誤執行,可在方法內設定alters_data=True
  • Template語法
    • {{ ... }} :內部存放變數
    • {% ... %} :內部放入標籤(Tag), if、for、ifequal
  • 標籤(Tag)
    • if
      • {% if isTrue %} ... {% endif %}:判斷isTrue是否為真,若為真,執行中間的區塊。
      • {% if isTrue %} ... {% else %} ... {% endif %}
      • {% if%}:可用 not、and、or。但and跟or不可同時使用。也不能用圓括弧。
    • for
      • {% for item in itemlist %} ...
        item {% endfor %}
        :迴圈
      • 可加個"reversed"反向搜尋。{% for item in itemlist reversed %}
      • {% empty %}:當空的時候執行。
      • {% for item in itemlist %} ...
        item {% empty %} ... {% endfor %
        }
      • {{ forloop.counter }}:for迴圈裡的變數,紀錄執行次數,第一次時為 1。
      • 其他變數:
        • forloop.counter0:從0開始。
        • forloop.revcounter:第一次為總數量,最後一次為1。
        • forloop.revcounter0:最後一次為0。
        • forloop.first:第一次執行時,為True。
        • forloop.last:最後一次執行時,為True。
    • ifequal
      • {% ifequal AAA BBB %} ... {% endifequal %}:如果AAA跟BBB相同,執行中間的區塊
    • 注釋:
      • {# This is a comment #}:中間的字串為注釋,但必須要為同一行,不可換行。
      • {% comment %} ... {% endcomment %}:兩者之間的區塊皆為注釋。
    • 過濾器:
      • {{ name | lower }}:所有字串變成小寫。
      • {{ my_list | first | upper }}:過濾器的結果,可以不斷傳送。
      • {{ bio | truncatewords : "30" }}:過濾器可以有參數,用冒號做分隔。

2010年5月29日 星期六

Django 安裝過程筆記

  • Python26跟3.0並存
    • 需要改變環境變數
    • 在eclipse中,則將lib的參考順序修改一下就好
      • window => Preference => Pydev => Interpreter - Python
  • django-admin.py位置
    • 位在Python26/Scripts
    • 需要將其位置 加入到環境變數裡面,否則直接打指令的話 會找不到
  • elipese與mysite的位置
    • mysite的位置 必須放到src底下,eclipse才找的到

2010年5月13日 星期四

文章閱讀 05/13

  • nominee:被提名人, A nominee is someone who is nominated for a job, position, or award.
  • mayoral :市長的
  • mayoral race: 市長選舉
  • municipality:自治市(直轄市)
  • municipal :地方政府的
  • designated:委派 指任(+as),
  • legislator:立法委員
  • Legislative Yuan: 立法院
  • former : 以前的
  • lawmaker:立法者
  • panel :專家咨詢組, a group of specialists who give their advice or opinion about something; a group of people who discuss topics of interest on television or radio 
  • incumbent :在職者
  • contender: 競爭者
  • Solidarity : 團結
  • lineup: 選手陣容
  • endorsement :支持,認可,a public statement or action showing that you support somebody/something
  • colleague : 同事
  • campaigning : 參加運動;進行競選
  • aspire: 渴望(成就)~ (to sth), to have a strong desire to achieve or to become something
  • securing: 牢固的;穩當的;牢靠的
  • usher : 引座員,(法庭的)傳達員,門衞,門房, an official who has special responsibilities in a court of law, for example allowing people in and out of the court
  • battle:戰役;戰鬥;搏鬥
  • unreserved : 無保留的, complete and without any doubts
  • aggravating : 加重的;增劇的;惡化的
  • solicit : 索求,請求…給予, ~ sth (from sb),  ~ (sb) (for sth) formal
  • formidable :令人敬畏的, if people, things or situations are formidable, you feel fear and/or respect for them, because they are impressive or powerful, or because they seem very difficult
  • stronghold : 有廣泛支持的地方, an area in which there is a lot of support for a particular belief or group of people, especially a political party

2010年5月11日 星期二

IELTS - 筆記 0510

  • 單字
    • faculty: 系
    • ward:病房
    • surgery:手術、門診室
    • surgeon:外科醫師
    • disorder:混亂
    • obstetrics:產科
    • intensive care:加護病房
    • intensive: 徹底的,密集的
    • radiography:X光照像
    • paediatrics: 小兒科
    • drip:滴下、點滴
    • fluid:液體, 流動的
    • wheelchair: 輪椅
    • -ology:學科、學目, small filed, refer to a particular science or subject
    • syringe:皮下注射器
    • needle:注射針頭
    • colostomy bag:人工肛門袋
    • Urine:尿
    • monologue:獨白,獨腳戲
    • creche:托兒所
    • opposite:對面的,on the other side of a particular area from somebody/something and usually facing them
    • crotches:拐杖(walking stick), 胯部,褲檔,
    • use sb/sth as crotches:把某人/某物當支柱.
    • Oxygen:氧氣
    • nutrients:營養的,營養物
    • absorb:吸收,理解
    • to tilt:使傾向於,
    • genetics:遺傳學
    • bacteria:細菌
    • Mosquito:蚊子
    • pollution:汙染
    • stress:壓力
    • sling:吊帶,a band of fabric that is tied around a person's neck and used to support a broken or injured arm
    • fabric:布料
    • cast:鑄模(石膏), a shaped container used to make an object.
    • plaster:熟石膏
    • exercise運動
    • -borne:運載的,輸送的
    • airborne:空氣傳播的
    • viruses:病毒
    • bandage:包紮
    • injection:注入,注射
    • covering up:掩蓋
    • prevent:預防,阻止
    • healthy diet:健康飲食
    • diet:(noun)日常飲食, (verb)節食
  • 位置描述
張貼選項




    2010年5月2日 星期日

    Unit Test基本原則

    UnitTest的基本原則



    1. 使用明確、自動、還有獨立的UnitTest。

    2. 先寫測試程式  再寫功能程式。

    3. 測試程式要包含正確版本的輸入 跟 正確版本的輸出。

    4. 測試程式要包含錯誤的輸入跟 錯誤時適當的回應。

    5. 重構時,要先修改測試程式,以反映新的需求。

    6. 重構是為了增進效能、適應性、可讀性、維護性或者其他要改善的項目。