tag:blogger.com,1999:blog-13421297137106521802024-03-21T11:49:23.109+08:00a worklet, nothing.记录与代码相关的这些事。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.comBlogger74125tag:blogger.com,1999:blog-1342129713710652180.post-27112808012657515432014-03-25T14:56:00.000+08:002014-03-25T15:00:38.811+08:00Django:View, UrlMappping,TemplateReference: <a href="https://docs.djangoproject.com/en/1.6/intro/tutorial03/">https://docs.djangoproject.com/en/1.6/intro/tutorial03/</a> <br />
【笔记性质,做好的材料还是原文!】<br />
<br />
Web page在Django来自于view。view可由Python的函数表示(定义),view也可由方法表示。如果view是由方法而非函数定义,则说这个view是基于类的。Django通过检查URL知道对应的view。URL到view的映射,在Django里被称作URLconfs。URLconf把URL patterns映射到views。URLconf就是对应module目录下的文件urls.py<br />
<br />
<b>1) 定义View</b><br />
官方例子,view的定义如下(views.py):<br />
from django.http import HttpResponse<br />
<br />
def index(request):<br />
return HttpResponse("Hello, world. You're at the poll index.")<br />
<br />
def detail(request, poll_id):<br />
return HttpResponse("You're looking at poll %s." % poll_id)<br />
<br />
上面的两个函数idnex和detail分别定义(或者说指向了)了两个view。<br />
<br />
<b>2) 定义URLconf</b><br />
作为<b>URLconf的文件urls.py</b>的内容如下,<br />
from django.conf.urls import patterns, url<br />
from<b><span style="color: red;"> polls </span></b>import views<br />
<br />
urlpatterns = patterns('',<br />
# ex: /polls/<br />
url(r'^$', <span style="color: #0b5394;"><b>views.index</b></span>, name='index'),<br />
# ex: /polls/5/<br />
url(r'^(?P<poll_id>\d+)/$', <span style="color: #134f5c;"><b>views.detail</b></span>, name='detail'),</poll_id><br />
)<br />
<br />
urls.py中的url方法的第二参数就是函数名。<br />
如,views.index,就是views.py中的函数index; urls.py中的views.detail,就是views.py中的函数detail。<br />
在urls.py中的url方法的第三参数就是视图名称。name='index' name='detail',就是分别定义了view的名字。<br />
url的第一参数定义了reuqest's url到view的匹配规则。<br />
<br />
**熟悉例子的时候,因为copy/past而没有修改对应的package名,结果导致在自己的application中,一直在调用无关应用polls的views.index方法。所以,最好不用用views这样的泛泛的名字做文件名,使用YourFeatuherViews这样具体的名称做文件名更好。<br />
<br />
<b>3) 把应用的url路由加入到project的路由定义中</b>:<br />
最后,在project目录下的urls.py中,加入你创建的application的URLconf:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>url(r'^autoInstaller/', include('autoInstaller.urls')),<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>url(r'^polls/', include('polls.urls')),<br />
<br />
<b>4)url到view的映射过程</b><br />
当请求被Django server接收到,首先有项目的URLconf进行处理,如果找到了与某个应用application对应的url,则按照url()里的定义截取掉匹配的部分,然后继续转给这个应用的URLconf,这个应用再进行匹配处理,比如根据应用的URLconfg来截取、分割url。最后转给与之匹配的view method。 这种处理方式带来一个好处——方便应用的共享、分发。加入你的应用到新的project中时,只需要修改project的URLconfig与你的应用的对应url匹配规则就好了。<br />
<br />
<b>5)Template<br />view 要么返回一个HttpResponse要么抛出Exception</b><br />
在view里,实际上你可以做很多事情,读数据库记录、生成PDF...但最后总期望的总是HttpResonse、或是Exception。页面显示方面的代码可以直接在view方法里写,当然最好是写到template里。Django的模板loader可以找到你应用下的template目录作为源导入其中的模板。在你应用的目录下建立目录tempaltes,在templates目录下再建立以app名为名字的目录。在这个目录下面保存这个app需要的模板。<br />
<div>
下面这个段是模板代码:<br />
<pre style="background-color: #e0ffb8; border-color: rgb(148, 218, 58); border-style: solid; border-width: 1px 0px; line-height: 16.799999237060547px; margin-bottom: 1em; margin-top: 1em; overflow: auto; padding: 0.3em 0.4em;"><span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">{%</span> <span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">if</span> <span class="nv" style="color: teal; margin-left: 0px; margin-right: 0px;">latest_poll_list</span> <span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">%}</span>
<span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">{%</span> <span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">for</span> <span class="nv" style="color: teal; margin-left: 0px; margin-right: 0px;">poll</span> <span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">in</span> <span class="nv" style="color: teal; margin-left: 0px; margin-right: 0px;">latest_poll_list</span> <span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">%}
</span><span style="color: navy;"> </span><span class="na" style="color: teal; margin-left: 0px; margin-right: 0px;">href=</span><span class="s" style="color: #bb8844; margin-left: 0px; margin-right: 0px;">"/polls/</span><span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">{{</span><span style="color: navy;"> </span><span class="nv" style="color: teal; margin-left: 0px; margin-right: 0px;">poll.id</span><span style="color: navy;"> </span><span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">}}</span><span class="s" style="color: #bb8844; margin-left: 0px; margin-right: 0px;">/"</span><span class="nt" style="color: navy; margin-left: 0px; margin-right: 0px;">></span><span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">{{</span><span style="color: navy;"> </span><span class="nv" style="color: teal; margin-left: 0px; margin-right: 0px;">poll.question</span><span style="color: navy;"> </span><span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">}}</span><span class="nt" style="color: navy; margin-left: 0px; margin-right: 0px;">
</span> <span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">{%</span> <span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">endfor</span> <span class="cp" style="color: #999999; font-weight: bold; margin-left: 0px; margin-right: 0px;">%}
</span><span class="cp" style="color: #999999; font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">{%</span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="k" style="font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">else</span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="cp" style="color: #999999; font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">%}</span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="nt" style="color: navy; font-family: Simsun; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;"></span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> No polls are available.</span><span class="nt" style="color: navy; font-family: Simsun; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;"></span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="cp" style="color: #999999; font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">{%</span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="k" style="font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">endif</span><span style="font-family: Simsun; line-height: normal; white-space: normal;"> </span><span class="cp" style="color: #999999; font-family: Simsun; font-weight: bold; line-height: normal; margin-left: 0px; margin-right: 0px; white-space: normal;">%}</span>
<span class="nt" style="color: navy; margin-left: 0px; margin-right: 0px;"></span></pre>
</div>
下面这个段是导入模板、渲染模板的代码:<br />
<pre style="background-color: #e0ffb8; border-color: rgb(148, 218, 58); border-style: solid; border-width: 1px 0px; line-height: 16.799999237060547px; margin-bottom: 1em; margin-top: 1em; overflow: auto; padding: 0.3em 0.4em;"><span class="kn" style="margin-left: 0px; margin-right: 0px;">from</span> <span class="nn" style="color: #555555; margin-left: 0px; margin-right: 0px;">django.http</span> <span class="kn" style="margin-left: 0px; margin-right: 0px;">import</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">HttpResponse</span>
<span class="kn" style="margin-left: 0px; margin-right: 0px;">from</span> <span class="nn" style="color: #555555; margin-left: 0px; margin-right: 0px;">django.template</span> <span class="kn" style="margin-left: 0px; margin-right: 0px;">import</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">RequestContext</span><span class="p" style="margin-left: 0px; margin-right: 0px;">,</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">loader</span>
<span class="kn" style="margin-left: 0px; margin-right: 0px;">from</span> <span class="nn" style="color: #555555; margin-left: 0px; margin-right: 0px;">polls.models</span> <span class="kn" style="margin-left: 0px; margin-right: 0px;">import</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">Poll</span>
<span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">def</span> <span class="nf" style="color: #990000; font-weight: bold; margin-left: 0px; margin-right: 0px;">index</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="n" style="margin-left: 0px; margin-right: 0px;">request</span><span class="p" style="margin-left: 0px; margin-right: 0px;">):</span>
<span class="n" style="margin-left: 0px; margin-right: 0px;">latest_poll_list</span> <span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">=</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">Poll</span><span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">.</span><span class="n" style="margin-left: 0px; margin-right: 0px;">objects</span><span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">.</span><span class="n" style="margin-left: 0px; margin-right: 0px;">order_by</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="s" style="color: #bb8844; margin-left: 0px; margin-right: 0px;">'-pub_date'</span><span class="p" style="margin-left: 0px; margin-right: 0px;">)[:</span><span class="mi" style="color: #009999; margin-left: 0px; margin-right: 0px;">5</span><span class="p" style="margin-left: 0px; margin-right: 0px;">]</span>
<span class="n" style="margin-left: 0px; margin-right: 0px;">template</span> <span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">=</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">loader</span><span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">.</span><span class="n" style="margin-left: 0px; margin-right: 0px;">get_template</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="s" style="color: #bb8844; margin-left: 0px; margin-right: 0px;">'polls/index.html'</span><span class="p" style="margin-left: 0px; margin-right: 0px;">)</span>
<span class="n" style="margin-left: 0px; margin-right: 0px;">context</span> <span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">=</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">RequestContext</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="n" style="margin-left: 0px; margin-right: 0px;">request</span><span class="p" style="margin-left: 0px; margin-right: 0px;">,</span> <span class="p" style="margin-left: 0px; margin-right: 0px;">{</span>
<span class="s" style="color: #bb8844; margin-left: 0px; margin-right: 0px;">'latest_poll_list'</span><span class="p" style="margin-left: 0px; margin-right: 0px;">:</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">latest_poll_list</span><span class="p" style="margin-left: 0px; margin-right: 0px;">,</span>
<span class="p" style="margin-left: 0px; margin-right: 0px;">})</span>
<span class="k" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">return</span> <span class="n" style="margin-left: 0px; margin-right: 0px;">HttpResponse</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="n" style="margin-left: 0px; margin-right: 0px;">template</span><span class="o" style="font-weight: bold; margin-left: 0px; margin-right: 0px;">.</span><span class="n" style="margin-left: 0px; margin-right: 0px;">render</span><span class="p" style="margin-left: 0px; margin-right: 0px;">(</span><span class="n" style="margin-left: 0px; margin-right: 0px;">context</span><span class="p" style="margin-left: 0px; margin-right: 0px;">))</span></pre>
context就是把模板变量映射到python对象的字典。在模板里通过{% %}把python代码扩起来。<br />
<br />
可以把上面那段代码通过<span class="kn" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">from</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="nn" style="color: #555555; line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">django.shortcuts</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="kn" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">import</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="n" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">render 简化成一行:</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="k" style="font-weight: bold; line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">return</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="n" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">render</span><span class="p" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">(</span><span class="n" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">request</span><span class="p" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">,</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="s" style="color: #bb8844; line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">'polls/index.html'</span><span class="p" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">,</span><span style="background-color: #e0ffb8; line-height: 16.799999237060547px;"> </span><span class="n" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">context</span><span class="p" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;">)</span><br />
<span class="p" style="line-height: 16.799999237060547px; margin-left: 0px; margin-right: 0px;"><br /></span>
<span style="line-height: 16.799999237060547px;">|</span><br />
<br />Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-45748175071737145222014-01-16T16:43:00.000+08:002014-01-17T09:46:55.796+08:00iOS笔记:CocoaPods<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
CocoaPods:是依赖管理工具。 <a href="http://www.raywenderlich.com/12139/introduction-to-cocoapods">http://www.raywenderlich.com/12139/introduction-to-cocoapods</a></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<span style="font-size: x-small;">吐槽一下:类似Maven、Gradle,当然更像gradle, 很怀疑maven是学院派的人主导的产品(一堆xml让谁看啊?!),gradle才有搞工程人的实际品质。</span></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<b>安装CocoaPods需要有:</b></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
1)Ruby 环境。下面的命令更新Ruby环境。</div>
sudo gem update --system <br />
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
2) Command Line Tools for Xcode</div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<b>安装CocoaPod:</b></div>
sudo gem install cocoapods<br />
pod setup<br />
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
</div>
<div>
<span style="font-family: Times New Roman;">执行sudo gem install cocoapods时会提示:</span><br />
<div style="font-family: 'Times New Roman'; text-align: -webkit-auto;">
<span style="font-family: Menlo; font-size: 11px;">rake's executable "rake" conflicts with /usr/bin/rake</span></div>
<span style="font-family: Menlo; font-size: 11px; text-align: -webkit-auto;">Overwrite the executable? [yN] y</span><br />
<div style="font-family: 'Times New Roman'; text-align: -webkit-auto;">
<span style="font-family: Menlo; font-size: 11px;">Successfully installed rake-10.1.1</span></div>
选择y覆盖,否则需要设置user的环境变量。Ref: <a href="http://guides.cocoapods.org/using/getting-started.html">http://guides.cocoapods.org/using/getting-started.html</a></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<span style="font-family: Menlo; font-size: 11px;"><br /></span></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<b>创建Podfile:</b></div>
open -e Podfile<br />
platform :iOS<br />
pod ‘AFNetWorking’, ‘0.9'<br />
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<b>运行pod install, 抓取Podfile里指定的库到本地。</b></div>
pod install<br />
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
用xcode打开pod install生成的workspace文件,而不是原来的project文件。否则会有下面的错误:<span style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">ld</span><span style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">:</span><span style="text-align: -webkit-auto;"> </span><span style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">library not found</span><span style="text-align: -webkit-auto;"> </span><span style="border: 0px; color: darkblue; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">for</span><span style="text-align: -webkit-auto;"> </span><span style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">-</span><span style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">lPods</span></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
RubyGems 是什么? </div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a "gem" and contains a package Ruby application or library.</div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
Gems can be used to extend or modify functionality in Ruby applications. Commonly they're used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work. </div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
<div style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-25845338104623918702014-01-16T16:12:00.000+08:002014-01-16T16:32:26.629+08:00尝试Django<br />
已经决定2014在公司自娱的项目,就用python来做了。这些日子熟悉了sublime,Paramiko,tenjin。把一些基本的操作点代码写出来了,如果只是做个命令行的东西,从技术点上该尝试的都已经ok了。<br />
<br />
我不喜欢在命令行敲命令去驱动程序,我喜欢在屏幕上输入参数,点击“Run”。。。运行的逻辑在心里,看到的应该只是状态...<br />
<br />
下面这篇文章讲了几个python上的web框架,不错。<a href="http://feilong.me/2011/01/talk-about-python-web-framework">http://feilong.me/2011/01/talk-about-python-web-framework</a><br />
<br />
我选了djiango,应该能省不少事吧。<a href="https://www.djangoproject.com/">https://www.djangoproject.com/</a><br />
<br />
参考入门教程: <a href="https://docs.djangoproject.com/en/1.6/intro/tutorial01/">https://docs.djangoproject.com/en/1.6/intro/tutorial01/</a><br />
<br />
上面的教程跟当前版本有出入,运行easy_install Sphinx 安装文档生成器。再到Django的doc目录运行命令“make html”来生成HTML文档。<br />
<br />
<br />
1)创建Djiango Project。<br />
可以把project理解成一个web应用,一个project会包含一些app。<br />
创建一个项目的根目录,运行:“python C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject oesTester”<br />
<br />
2)默认的创建出来的project会带有几个app,其中的一些app需要数据库的支持,所以,需要运行“python manage.py syncdb”来在数据库中创建一些表。最后会提示你创建后台管理应用的管理员账号、密码。<br />
<br />
3)创建Project里的一个app。<br />
可以把一个app理解成负责某项功能的模块。app的python代码可以在任何python path里。<br />
python C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject oesTester<br />
一个project有多个apps组成。在DJango中model是data class的意思,对应于ORM里的数据模型。<br />
下面的命令创建一个app,名称是"autoInstaller"。<br />
python manage.py startapp autoInstaller<br /><br />
启动Web Server: <span class="pre" style="background-color: white; color: #234f32; font-family: monospace; font-size: 12px; line-height: 16.796875px; margin-left: 0px; margin-right: 0px; white-space: nowrap;">python</span><span style="background-color: white; color: #234f32; font-family: monospace; font-size: 12px; line-height: 16.796875px; white-space: nowrap;"> </span><span class="pre" style="background-color: white; color: #234f32; font-family: monospace; font-size: 12px; line-height: 16.796875px; margin-left: 0px; margin-right: 0px; white-space: nowrap;">manage.py</span><span style="background-color: white; color: #234f32; font-family: monospace; font-size: 12px; line-height: 16.796875px; white-space: nowrap;"> </span><span class="pre" style="background-color: white; color: #234f32; font-family: monospace; font-size: 12px; line-height: 16.796875px; margin-left: 0px; margin-right: 0px; white-space: nowrap;">runserver</span><br />
<br />
4) 创建model的步骤略去,因为这个项目第一版不准备使用DB.<br />
<br />
<br />
5) 访问 ,页面没有加载css,开始一直以为是Django static的配置问题。后来注意到console有“mimetypes.py", line 249, in enum_types”之类的信息,原来这是python2.7的一个bug导致的。<br />
修改mimetypes.py,注释掉下面这些行<br />
#try:<br />
# ctype = ctype.encode(default_encoding) # omit in 3.x!<br />
#except UnicodeEncodeError:<br />
# pass<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-31076681846388334152013-12-27T13:21:00.002+08:002013-12-27T13:21:54.462+08:00SublimeText的插件安装最后还是同时装上了SublimeText2和3。<br />
<br />
SublimtText用来安装插件的package controller插件,需要从console安装。ctrl+`<br />
如果你系统使用python2,使用下面语句:<br />
<div>
<span style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler(</span><span style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">))); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation') </span></div>
如果你系统使用python3,使用下面语句:<br />
import urllib.request,os;pf = 'Package Control.sublime-package';ipp = sublime.installed_packages_path();urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()));open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())<br />
<br />
如果,你要通过代理上网并且不是windows操作系统(Windows操作系统使用IE的代理配置),需要把代理配置写到<span style="font-family: 'Times New Roman'; orphans: 2; widows: 2;">urllib2.ProxyHandler()里,比如:</span><br />
<div>
<span style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">urllib2.ProxyHandler({'http':</span><span style="color: #7600d8; font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">'cn-proxy.abc.com:80'</span><span style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;">})</span></div>
<div>
<span style="font-family: 'Times New Roman'; orphans: 2; text-align: -webkit-auto; widows: 2;"><br /></span></div>
<div style="orphans: 2; widows: 2;">
<span style="font-family: Times New Roman;">安装pylint,需要你的python环境里有lint.py, 如果你没有lint.py, 就先安装pip, easy-setup什么的,参照这帖子:</span><a href="http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows">http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows</a></div>
<div style="orphans: 2; widows: 2;">
<br /></div>
<div style="orphans: 2; widows: 2;">
安装完pylint,还要把lint.py的路径写到pylint的用户配置文件,比如"pylint_path": "C:\\Python27\\Lib\\site-packages\\pip\\vendor\\html5lib\\filters"</div>
<div style="orphans: 2; widows: 2;">
<br /></div>
<div style="orphans: 2; widows: 2;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-5502790039691201662013-09-30T15:00:00.005+08:002013-10-12T11:15:54.876+08:00Oracle ADG 环境搭建<h2 style="background-color: white; color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-weight: normal; line-height: 24px; margin: 0px; padding: 0px;">
<strong style="line-height: inherit;">Oracle官方文档</strong></h2>
<div class="content" style="background-color: white;">
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
《Oracle Data Guard Broker》 <a href="http://docs.oracle.com/cd/B19306_01/server.102/b14230/toc.htm" style="color: #027ac6; line-height: inherit; text-decoration: none;">http://docs.oracle.com/cd/B19306_01/server.102/b14230/toc.htm</a>《RAC基本概念介绍》 <a href="http://docs.oracle.com/cd/E11882_01/rac.112/e17264/intro_tdprc.htm#CHDGDCFE" style="color: #027ac6; line-height: inherit; text-decoration: none;">http://docs.oracle.com/cd/E11882_01/rac.112/e17264/intro_tdprc.htm#CHDGDCFE</a>《SRVCTL文档》 <a href="http://docs.oracle.com/cd/E11882_01/rac.112/e16795/srvctladmin.htm#RACAD5011" style="color: #027ac6; line-height: inherit; text-decoration: none;">http://docs.oracle.com/cd/E11882_01/rac.112/e16795/srvctladmin.htm#RACAD5011</a></div>
<h3 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 17px; font-weight: normal; line-height: inherit; margin: 0px; padding: 0px;">
</h3>
<h2 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-weight: normal; line-height: 24px; margin: 0px; padding: 0px;">
</h2>
<h2 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-weight: normal; line-height: 24px; margin: 0px; padding: 0px;">
<strong style="line-height: inherit;">不错的网络文章</strong></h2>
<h3 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 17px; font-weight: normal; line-height: inherit; margin: 0px; padding: 0px;">
<span style="color: #333333; font-size: 13px; line-height: inherit;"><a href="http://www.2cto.com/database/201303/194696.html" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Oracle Data Guard理论知识》</a> 这篇文章对于理解DataGuard如何利用log进行了介绍。<br style="line-height: inherit;" /><a href="http://www.dbabeta.com/2009/learn-data-guard-broker_basics.html" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Data Guard broker系列》</a><a href="http://www.oracle-base.com/articles/11g/data-guard-setup-11gr2.php" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Data Guard Physical Standby Setup in Oracle Database 11g Release 2》</a> 这篇文章有坑(没有提及_DBG, _DGMGRL),但总体顺序不错。<br style="line-height: inherit;" /><a href="https://blogs.oracle.com/xpsoluxdb/entry/4_steps_to_create_a_physical_standby_database" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Four Steps to create a Physical Standby Database》</a> 这篇文章轮廓写得清晰。 上篇文章中没有提及listener.ora文件中的_DGB , _DGMGRL这两个static listener,是绝对的坑。 _DGB是Datagurad Broker用来侦听不同节点心跳的。_DGMGRL是用来保证数据库down的时候能够访问的。</span></h3>
<h3 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 17px; font-weight: normal; line-height: inherit; margin: 0px; padding: 0px;">
<span style="color: #333333; font-size: 13px; line-height: inherit;"><a href="http://oracledba-sharinganexperience.blogspot.sg/2012/12/how-to-add-and-remove-databases-from.html" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《How to add and remove databases from Oracle cluseter》</a>这篇主要示例了如何使用crvctl。</span></h3>
<h3 style="color: #494949; font-family: Helvetica, Arial, sans-serif; font-size: 17px; font-weight: normal; line-height: inherit; margin: 0px; padding: 0px;">
<span style="color: #333333; font-size: 13px; line-height: inherit;"> </span></h3>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<h2 style="font-family: Helvetica, Arial, sans-serif; font-size: 19px; font-weight: normal; line-height: 24px; margin: 0px; padding: 0px;">
<strong style="line-height: inherit;">安装中遇到的一些问题&解决:</strong></h2>
</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
1)</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<strong style="line-height: inherit;">现象:</strong></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<div style="line-height: inherit;">
SQL> STARTUP NOMOUNT PFILE=’/tmp/initDB11G_stby.ora’;<br />
ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated<br />
ORA-01262: Stat failed on a file destination directory<br />
Linux-x86_64 Error: 2: No such file or directory<br />
SQL></div>
<div style="line-height: inherit;">
<strong style="line-height: inherit;">解决:</strong></div>
<div style="line-height: inherit;">
因为在standby上创建的fast_recovery_area时,把一个字母写错了…<br />
<br /></div>
<div style="line-height: inherit;">
</div>
</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
2)<br />
<strong style="line-height: inherit;">现象:</strong><br />
Warning: ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
<strong style="line-height: inherit;">解决:</strong></div>
<div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
先查看那些不一致,然后更正之。<br />
DGMGRL> show database 'db11g_stby' 'InconsistentProperties';</div>
<div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
edit database 'db11g_stby' set property 'ArchiveLagTarget'=0;<br />
<span style="color: #2b6fb6; font-size: 14px; line-height: inherit;">可参考官方文档 <a href="http://docs.oracle.com/cd/E11882_01/server.112/e17023/cli.htm" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">http://docs.oracle.com/cd/E11882_01/server.112/e17023/cli.htm</a></span></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
3)<br />
<strong style="line-height: inherit;">现象:</strong><br />
分别进入primary sqlplus , standby sqlplus执行—-》<br />
SQL> select flashback_on from v$database;<br />
SQL> alter database flashback on;<br />
在standby 上<br />
SQL> alter database flashback on;<br />
alter database flashback on<br />
*<br />
ERROR at line 1:<br />
ORA-01153: an incompatible media recovery is active<br />
SQL><br />
<strong style="line-height: inherit;">解决:</strong>SQL> STARTUP MOUNT;<br />
ORACLE instance started.</div>
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
Total System Global Area 2421825536 bytes<br />
Fixed Size 2228880 bytes<br />
Variable Size 1358957936 bytes<br />
Database Buffers 1040187392 bytes<br />
Redo Buffers 20451328 bytes<br />
Database mounted.<br />
SQL> alter database flashback on;<br />
Database altered.</div>
</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
4)</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<strong style="line-height: inherit;">现象:</strong>switchover失败<br />
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
</div>
<div style="line-height: inherit;">
<div style="line-height: inherit;">
DGMGRL> switchover to db11g_stby;<br />
<span style="color: red; line-height: inherit;">Performing switchover NOW, please wait…<br style="line-height: inherit;" />Error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor<br style="line-height: inherit;" />Error: ORA-16625: cannot reach database “db11g_stby”<br style="line-height: inherit;" />Failed.<br style="line-height: inherit;" />Unable to switchover, primary database is still “db11g”</span></div>
<div style="line-height: inherit;">
</div>
<div style="line-height: inherit;">
DGMGRL> show configuration;<br />
Configuration – myconfigProtection Mode: MaxAvailability<br />
Databases:<br />
db11g – Primary database<br />
db11g_stby – Physical standby databaseFast-Start Failover: DISABLED<br />
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
</div>
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
Configuration Status:<br />
ORA-16623: database detected role change<br />
ORA-16625: cannot reach database “db11g”<br />
DGM-17017: unable to determine configuration status<br />
DGMGRL><br />
<strong style="line-height: inherit;">解决:</strong>查看一下stby数据库broker参数,发现staticConnectorIdentifier默认使用1521端口。而我用的stby数据库是1522端口。<br />
DGMGRL> show database verbose ‘db11g_stby’;<br />
RecvQEntries = ‘(monitor)’<br />
SidName = ‘DB11G’<br />
StaticConnectIdentifier = ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=<span style="color: #e30000; line-height: inherit;"><b style="line-height: inherit;">1521</b></span>))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))’<br />
StandbyArchiveLocation = ‘USE_DB_RECOVERY_FILE_DEST’</div>
</div>
</div>
</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
可以通过一下命令之一修改之:</div>
<div>
<div>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px; line-height: 20px;">//通过dgmgrl:</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px; line-height: 20px;">edit database db11g_stby set property StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))';</span></span></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
或者 sqlplus:</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
alter system set StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slc01bme)(PORT=<span style="color: #e30000; line-height: inherit;"><b style="line-height: inherit;">1522</b></span>))(CONNECT_DATA=(SERVICE_NAME=DB11G_STBY_DGMGRL.us.oracle.com)(INSTANCE_NAME=DB11G)(SERVER=DEDICATED)))' scope=both;<br />
<strong style="line-height: inherit;">参考:</strong></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<a href="http://blog.sina.com.cn/s/blog_70bb81860101bgnr.html" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《解决Oracle DataGuard Broker出现的TNS-12514错误》</a><a href="https://blogs.oracle.com/xpsoluxdb/entry/4_steps_to_create_a_physical_standby_database" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Four steps to create a Physical Standby Database》</a> 这篇文章里,是在添加了_DBG, _DGMGRL两个服务名之后,执行诸如如下的命令来确保提供合适的conenction给DG broker。下面的命令因为使用服务名而优于前文的链接字符串。<br />
edit database db11g set property staticConnectidentifier=’DB11G’;<br />
edit database db11g_DG1 set property staticConnectidentifier=’DB11G_DG1′;</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
5)<br />
<strong style="line-height: inherit;">现象:</strong>-bash-3.2$ srvctl add ons<br />
PRCR-1063 : Failed to create context<br />
PRKH-1010 : Unable to communicate with CRS services.<br />
PRKH-1000 : Unable to load the SRVM HAS shared library<br />
PRKN-1008 : Unable to load the shared library “libsrvmhas11.so”<br />
or a dependent library, from<br />
LD_LIBRARY_PATH=”/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib”<br />
[java.lang.UnsatisfiedLinkError: /scratch/dahyuan/app/oracle/product/11.2.0/grid/lib/libsrvmhas11.so: libasmclnt11.so: cannot open shared object file: No such file or directory]<br />
解决:<br />
一种是你的server上真的缺少一些开发包,需要你编译安装。但我这里是因为LD_LIBRARY_PATH的问题,当时libary path没有/usr/lib和/usr/local/lib这两个目录。加上之后再运行root.sh就好了。 LD_LIBRARY_PATH应该至少包括/scratch/dahyuan/app/oracle/product/11.2.0/grid/lib:/usr/lib:/usr/local/lib。<br />
参考:<br />
<a href="http://linux.net527.cn/fuwuqiyingyong/Oracle/2012/0113/45411.html" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《Oracle 安装 clusterware时遇到的问题》</a></div>
<div style="line-height: inherit; margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
6)<br />
<strong style="line-height: inherit;">现象:</strong>-bash-3.2$ srvctl start ons<br />
#<br />
# An unexpected error has been detected by HotSpot Virtual Machine:<br />
# SIGSEGV (0xb) at pc=0x00002ada0b2b3a84, pid=2082, tid=47115974751584<br />
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.5.0_24-rev-b08 mixed mode)</div>
</div>
</div>
</div>
</div>
<div style="margin-bottom: 1.2em; margin-top: 0.6em; padding: 0px;">
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
# Problematic frame:</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
# V [libjvm.so+0x3afa84]</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
#</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
# An error report file with more information is saved as hs_err_pid2082.log</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
#</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
# If you would like to submit a bug report, please visit:</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
# <a href="http://java.sun.com/webapps/bugreport/crash.jsp" rel="nofollow" style="color: #027ac6; line-height: inherit; text-decoration: none;">http://java.sun.com/webapps/bugreport/crash.jsp</a></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
#</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
/scratch/dahyuan/app/oracle/product/11.2.0/dbhome_1/bin/srvctl: line 240: 2082 Aborted $JRE $JRE_OPTIONS -DORACLE_HOME=$ORACLE_HOME -classpath $CLASSPATH $SRVM_PROPERTY_DEFS oracle.ops.opsctl.OPSCTLDriver “$@”</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<strong style="line-height: inherit;">解决:</strong></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
这个是因为使用了Database_HOME里的srvctl。应该使用grid_HOME/bin里的srvctl。</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
参考:</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<a href="http://docs.oracle.com/cd/E11882_01/rac.112/e16795/srvctladmin.htm#RACAD5011" style="color: #027ac6; line-height: inherit; text-decoration: none;" target="_blank">《SRVCTL文档》</a> To manage Oracle ASM on Oracle Database 11g release 2 (11.2) installations, use the SRVCTL binary in the Oracle Grid Infrastructure home for a cluster (Grid home). If you have Oracle RAC or Oracle Database installed, then you cannot use the SRVCTL binary in the database home to manage Oracle ASM.</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<br /></div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
7)</div>
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<strong style="line-height: inherit;">现象:</strong></div>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;">DGMGRL> ENABLE FAST_START FAILOVER;</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;">Error: ORA-16651: requirements not met for enabling fast-start failover</span></span><br />
<strong style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">解决:</strong><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;">在primary 和 standby上用sqlplus 都执行, </span><span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;"> alter database flashback on;</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;">8)</span><br />
<div style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">
<strong style="line-height: inherit;">现象:</strong></div>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;">DGMGRL> show database verbose 'db11g_stby';</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;">出现以下警告,</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;"> Database Warning(s):</span></span><br />
<br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;"> ORA-16826: apply service state is inconsistent with the DelayMins property</span></span><br />
<strong style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: inherit;">解决:</strong><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;">在DGMGRL里执行,disable configuration; 再执行 enable configuration; 就可以解决。</span></span><br />
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-size: 12px;"><br /></span></span>
<span style="color: #494949; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;"><br /></span>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-10356088053938725552013-01-14T11:26:00.000+08:002013-01-14T12:24:16.883+08:00【翻译】The “reassociation” business of Fusion Middleware原文出处:<a href="http://fusionsecurity.blogspot.jp/2011/10/reassociation-business.html">http://fusionsecurity.blogspot.jp/2011/10/reassociation-business.html</a>
下面大致翻译了一下,不精准,笔记性质。<br />
<br />
从Fusion Middleware 11.1.1.4开始,OPSS(Oracle Platform Security Service)支持三种类型的安全存储(Security Store):文件、OID(Oracle Internet Directory)以及Oracle DataBase。当weblogic server的domain刚被创建出来时,默认地,OPSS是和文件类型的存储相关联的。文件存储比较适合开发阶段。对于生产环境,不推荐文件存储类型(请参考“<a href="http://docs.oracle.com/cd/E21764_01/core.1111/e10043/cfgauthr.htm#CHDEFHHA"> Multiple Nodes Servers Environments</a>”)。如果你的运行环境是在一个台机器上只有唯一的一个weblogic domain、一个weblogic server,文件类型存储也是能工作的。但是99.99%的情况,你的SOA、WebCenter环境是运行在集群环境下的多个服务器上。文件存储不提供这种伸缩性,这种情况下,你应该考虑OID或者Oracle DataBase。<br />
<br />
实际上,很多的Fusion应用时使用OID。:)
OPSS安全存储由policy,credential,keys以及audit services组成。注意:我没有提及identity store service。因为,OPPS把identity store service'委托给了在weblogic server里配置的'identity provider'。
OPSS不是一个产品,它是Fusion Middleware使用的一组安全服务。
这个帖子十分详细地讲述了如何配置weblogic server domain使用以上的三种不同security store。这也是"reassociation(关联)"这个词的来历。
下面的内容和 “<a href="http://docs.oracle.com/cd/E21764_01/core.1111/e10043/cfgauthr.htm#CHDHGAJG">Configuring OPSS Security Store</a>”(强烈推荐阅读)有些重叠。<br />
<br />
<br />
在更进一步讲述association之前,我们先说说jps-config.xml的关键点。<br />
<br />
<b>jps-config.xml</b><br />
OPSS使用这个文件描述它所提供的服务。通过设置系统属性–Doracle.security.jps.config你可以指定OPSS从哪里读取这个文件,通常在JRF(Java Required Files)domain的setDomainEnv.sh里设置这个文件的位置。<br />
缺省的位置是${DOMAIN_HOME}/config/fmwconfig/jps-config.xml。(定义在变量EXTRA_JAVA_PROPERTIES里)。建议不要轻易修改jps-config.xml,因为jps-config.xml包含了许多对其它文件的引用。
当以通过config.sh脚本来创建BPM,SOA或者WebCenter 域(domain)时,JRF template会自动被选中,因为这些鱼都依赖JRF。
jps-config.xml是作用于域范围的配置文件。并不存在针对server或者application这一层起作用的jps-config.xml文件。但是,jps-config.xml里context的概念,可以让你让不同的application使用不同的安全服务。这是另外一个话题了。
当执行了reassociation操作,配置的改变会被写入jps-config.xml。破损的jps-config.xml会让你的domain运行在不稳定的状态。所以,对jps-config.xml的修改要慎之又慎。不要手工修改这个文件,而是要用Enterprise Manager或者wlst。<br />
<br />
<b>The Policy Store</b>
Policy store保存着Fusion Middleware实例上运行的application的所需要的全部安全策略,包括赋予pricials(users,groups, application roles)以及code 的允许权限。
比如,如果你查看BPM域上OOTB的policy store,你就会发现这些策略分成四组,供4个应用 (OracleBPMProcessRolesApp, OracleBPMComposerRolesApp, b2bui and soainfra)使用。另外还有一组对部署在这个域的所有应用都生效的code-source策略。
jps-config.xml文件里的default context定义了Fusion Middleware里所有应用都用到的服务。
<br />
<b><br /></b>
<b>The Credential Store</b>
Credential store保存着Fusion Middleware应用连接到其它系统所用的凭证。这不同于下面要讲到的boostrap credentials。
<serviceinstance location="./" name="credstore" provider="credstoressp">
<description>File Based Credential Store Service Instance</description> </serviceinstance><br />
<b><br /></b>
<b>Reassociating to OID</b>
有两种方式做reassociation。 Enterprise Manager和wlst。(只大致介绍一下关键参数的含义,具体见原文。)<br />
EM界面里的:
Root DN: 这个需要再做reassociation之前在OID里创建。
Create New Domain: 这里不是表示“创建一个新域”的意思。这里的意识是说,要关联的OID是不是要要从源security store导入数据进行初始化。不选择这个checkbox意味着,你有多个domain共享这个security store。
Domain Name: 这里方便起见,EM使用weblogic域名。但实际上,它可以是任意名字。这个名字用于标识它为一个container节点。多个weblogic域可以绑定到相同的container,但是,一个weblogic域不能绑订到不同的container。<br />
<br />
wlst里的参数:
> reassociateSecurityStore(domain="farm1", admin="cn=orcladmin",
password="welcome1", ldapurl=ldap://localhost:3060, servertype="OID",
jpsroot="cn=SecurityStore",[join=”trueOrfalse”])
理解了EM的输入,wlst就容易理解了。join这个参数,对应着EM里的是否'Create new domain'。<br />
<br />
<b>Bootstrap cwallet.sso </b><br />
当reassociated到OID时,weblogic需要知道连接到OID服务器的登录凭证。缺省地,这些凭证被保存在jps-config.xml bootstrap.credstore指定的位置。
<jpscontext name="bootstrap_credstore_context">
<serviceinstanceref ref="bootstrap.credstore">
</serviceinstanceref></jpscontext>
<serviceinstance location="./bootstrap" name="bootstrap.credstore" provider="credstoressp">
<property name="location" value="./bootstrap">
</property></serviceinstance>
如果以后需要修改这个credentials,可以使用以下wlst命令:
> modifyBootStrapCredential(jpsConfigFile='<filepath>',username='<username>', password='<password>')
这里
jpsConfigFile = 有效的jps config文件路径。
username = 用户名
password = 新密码
比如
> modifyBootStrapCredential(jpsConfigFile='/opt/wls/oracle/middleware/user_projects/domains/soa_domain/config/fmwconfig/jps-config.xml',username='cn=orcladmin', password='welcome1')
</password></username></filepath>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-27855251271315159962012-09-11T16:09:00.001+08:002012-09-11T16:09:47.527+08:00(ZT) MAC 常用软件Designer Daily的Mirko整理分享的一份免费Mac软件列表,大多数适用于自由职业者。当然,这个概念很模糊,没有什么软件是只有自由职业者才使用的,自由职业者本身又是一个包罗万象、异常模糊的概念。
所以, 所有Mac用户都可以看看,Windows用户也可以看,因为Mirko同时使用Mac和Windows,他不但列出了免费Mac软件,还包括相关的Windows平台下的替换方案。
1、Name Changer
重命名多个文件,可以完美地一次给多个文件重新命名。当你处理图片的时候,它是你的最佳助手。
2、Anxiety
这款轻量级的软件可以帮助你管理简单的任务列表。如果你不想用复杂的GTD软件,那么这款软件最适合你。
3、Cyberduck
拥有漂亮界面的FTP软件,并且整合了多个文本编辑器。
4、Adium
这款开源的即时通讯软件可以让你登陆所有的IM账号。
5、Carbon Copy cloner
帮助你快速建立一个可以引导启动的磁盘镜像。
6、The Unarchiver
兼容多种模式的解压缩软件。
7、AppCleaner
帮助你在删除软件的时候不留下任何垃圾文件。
8、The Gimp
图像处理软件,photoshop的替代品。
9、Skype
Windows下也可以使用
10、firefox
免费、开源的浏览器,拥有大量插件。
Windows下也可以使用
11、Caffeine
不要让你的Mac休眠,给它点咖啡因吧。
12、Burn
高级CD和DVD刻录软件。
13、Handbrake
DVD到Mpeg格式的转换软件,可以帮助你转换DVD影片。
Windows下也可以使用
14、Audacity
开源的录音、音频编辑软件。
Windows下也可以使用
15、Smultron
Mac下强大的文本编辑器。
Windows替代方案
16、InkScape
开源的矢量编辑软件,Illustrator的替代品。
Windows也可以使用
17、Freemind
脑图软件,我最喜欢的整理思维的方法。
Windows下也可以使用
18、Disk Inventory X
Mac OS X下的磁盘检查工具,帮助你快速查看是什么占用了磁盘空间。
Windows替代方案
19、Colloquy
高级IRC客户端,拥有良好的用户界面。
Windows替代方案
20、Neo Office
开源的办公软件套装,Word和Excel的替代品。
Windows替代方案
21、QuickSilver
快速运行程序的软件,真正提高你的效率。
Windows替代方案
22、NetNewsWire
我最喜欢的RSS阅读器,每天早晨喝咖啡的时候打开。
Windows替代方案
23、DeepVacuum
帮助你通过http或ftp协议下载完整的网站或页面。
Windows替代方案
24、HyperDither
批量修改图片尺寸的软件,如果你不喜欢用Photoshop的动作,这款软件可以为你节省时间。
Windows替代方案
25、Transmission
这款BT软件让你分享文件变得非常简单。
Windows替代方案
英文原文: 25 free Mac Apps for freelancers
中文译文: yeeyanAnonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-79770406486232248782010-10-22T15:59:00.000+08:002010-10-22T16:00:14.014+08:00几个第三方库的交叉编译交叉编译环境根目录在/usr/coma/v4t_le<br />编译器: /usr/coma/v4t_le/bin<br />目标运行环境及库: /usr/coma/v4t_le/target /usr/coma/v4t_le/target/usr/lib<br /><br />在执行交叉编译之前,先设置2个环境变量:<br />export CC=/usr/coma/v4t_le/bin/arm_v4t_le-gcc<br />export CXX=/usr/coma/v4t_le/bin/arm_v4t_le-g++<br /><br />expat-2.0.1<br />libarchive-2.5.5<br />这两个库的交叉编译没有什么麻烦,进入到源文件路径后:<br />./configure --host=arm4tl-hardhat-linux --prefix=/opt/coma/v4t_le/target/usr<br />make<br />make install<br />执行这三个命令就基本好了。<br /><br />zlib-1.2.5 更简单,<br />./configure --prefix=/opt/coma/v4t_le/target/usr|<br />make<br />make install<br /><br />OpenSSL的交叉编译相对麻烦:(Reference: Linux下第三方库交叉编译 - lee353086的专栏 - CSDN博客.)<br />#openssl版本0.9.8o<br />方式一:生成静态库<br /># ./config --prefix=/home/kagula/arm432 no-asm shared os/compiler:arm-linux-gcc<br />修改MakeFile文件中的以下变量<br />EX_LIBS= -ldl<br />AR= arm-linux-ar $(ARFLAGS) r<br />ARD=arm-linux-ar $(ARFLAGS) d<br />RANLIB= arm-linux-ranlib<br />#Make<br />#Make install<br />生成libssl.a libcrytpo.a (这两个库的使用顺序不能颠倒)<br />(把arm-linux-ar 要换成你的交叉编译器对应的文件名:<br />我这里是/opt/coma/v4t_le/bin/arm_v4t_le-ar<br />相应的arm-linux-ranlib 也要替换为/opt/coma/v4t_le/bin/arm_v4t_le-ranlib。)<br />备注:【1】使用os/compiler选项会导致shared参数不起作用,即只能生成静态库【2】如果刚编译成x86版本的,编译成arm版本之前记得要make clean下清除掉x86版本的目标文件。<br />方式二:生成动态库<br />#CC=arm-linux-gcc ./config no-asm shared --prefix=/home/kagula/arm432<br />如上修改MakeFile文件中的变量<br />#Make<br />#Make install<br />在安装目录就会看到libssl.so及libcrypto.so相关文件<br /><br />gSoap<br />这个包的交叉编译是最麻烦的,在尝试过程中(由于环境的不同)你可能会发现需要一些其它的第三方包,比如Bison, Flex,M4,甚至需要在/usr/lib下建立一个libssl.so的软链接。另外比较特殊的是,你需要一个现在宿主机上编译一个本地的gsoap库,因为在交叉编译wsdl目录下文件是,需要执行gsoapcpp2,而目标平台的gsoapcpp2是不可能在宿主机行执行的。所以,还需要修改wsdl里的Makefile文件重新修改SOAP的值为: SOAP=soapcpp2 。 当然soapcpp2需要在你的宿主机环境的PATH里。<br /><br />问题1: 交叉编译gsoap的时候总出现'malloc' has not been declared 的错误。在网上查了下,是因为cstdlib的一个库bug。<br />1. 将#define malloc rpl_malloc 屏蔽;<br />2.将#define HAVE_MALLOC 0 更改为:#define HAVE_MALLOC 1<br /><br />问题2: “找不到yacc”的问题。Bison是优于yacc的方案:http://www.gnu.org/software/bison/<br /><br />问题3: ./congifugre bison有说需要GNU M4 1.4.13 。 M4主页:http://www.gnu.org/software/m4/<br /><br />问题4:还需要GNU Flex http://flex.sourceforge.net/ 这个需要安装到宿主机环境。<br /><br />问题5:不能执行soapcpp2。 解决办法:在宿主机上编译一个本地的gsoap库。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-72318926985858205362010-10-13T11:24:00.002+08:002010-10-13T11:24:39.540+08:00nm gcc参数顺序<div class="gmail_quote"><div><div>用nm可以查看目标文件以及库文件中包含的方法。如果链接中出现undefined reference,可以用nm去查看一下相关的库中是否存在那个方法进行错误排除。</div><div><br /></div><div>$(OBJDIR)/stdsoap2.o: $(COMA_libs)/$(LIB_GSOAP)/stdsoap2.c $(COMA_libs)/$(LIB_GSOAP)/plugin/httpform.c $(COMA_libs)/$(LIB_GSOAP)/plugin/httpget.c</div> <div><span style="white-space:pre-wrap"> </span>$(CC) -Os -I$(COMA_libs)/$(LIB_GSOAP) -L $(COMA_libs)/$(LIB_GSOAP) $(THREAD) -c -o $@ -DWITH_OPENSSL $^</div></div><div>上面是有问题的,需要调整参数顺序。注意-c -o的顺序。</div>$(OBJDIR)/stdsoap2.o: $(COMA_libs)/$(LIB_GSOAP)/stdsoap2.c $(COMA_libs)/$(LIB_GSOAP)/plugin/httpform.c $(COMA_libs)/$(LIB_GSOAP)/plugin/httpget.c<br /> $(CC) -Os -I$(COMA_libs)/$(LIB_GSOAP) -L $(COMA_libs)/$(LIB_GSOAP) $(THREAD) <font color="#800000">-DWITH_OPENSSL -c -o $@ $< </font><br clear="all"><br /><div>下面是原来指令中缺少了两个目标文件,不能链接。<br /><font color="#0000ff" size="2" face="Arial">COMA: $(OBJECT_FILES) $(API_FILES) $(ADAPTER_FILES) $(GUI_FILES) $(ENV_OBJECT_FILES) $(OBJDIR)/stdsoap2.o $(OBJDIR)/NE3S_serverlib.o $(OBJDIR)/NE3S_clientlib.o $(OBJDIR)/env.o $(OBJDIR)/app.o bin/tree.o<br /> $(CC) -g -Xlinker -Map -Xlinker COMA.map -Os -L $(COMA_libs)/$(LIB_GSOAP) -L $(COMA_libs)/zlibonly-dll/lib -L $(COMA_libs)/libarchive-2.5.5/.libs $(COMA_libs)/$(LIB_GSOAP)/libgsoap.a $(THREAD) -pedantic -o COMA $(GUI_FILES) $(ENV_OBJECT_FILES) $(API_FILES) $(ADAPTER_FILES) $(OBJECT_FILES) $(OBJDIR)/stdsoap2.o $(OBJDIR)/NE3S_serverlib.o $(OBJDIR)/NE3S_clientlib.o $(OBJDIR)/env.o $(OBJDIR)/app.o bin/tree.o <strong><font color="#800000"><span>../</span>$(OBJDIR)/httpget.o <span>../</span>$(OBJDIR)/httpform.o</font></strong> $(COMA_libs)/libarchive-2.5.5/.libs/libarchive.a -DWITH_OPENSSL -lcrypto -lexpat -lssl -lz </font> </div> </div>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-87291417332073726982010-09-17T12:57:00.002+08:002010-09-17T13:27:50.887+08:00在项目中Struts2的form需要由变量来定义。如果使用<s:property value="..."><br />通过这个%{#variableName} 可以解决这个问题。<br /><br />比如:<br /><s:form action ="changeOwner" id="changeOwnerForm%{#device.id}">Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-16666096433161049802010-06-09T11:24:00.006+08:002010-06-09T12:37:19.766+08:00运行时改变log4j属性。log4j特性一般由配置文件决定,如果需要在运行时进行改变,可以通过以下类似的方法解决:<br /><code><br />Appender appender = Logger.getRootLogger().getAppender("devLogFile");<br />RollingFileAppender fa = (RollingFileAppender) appender;<br />fa.setMaxFileSize(logSizeStr);<br />fa.<span style="font-weight:bold;">activateOptions()</span>;<div></code></div>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-36064138618792083662009-08-24T15:52:00.001+08:002009-08-24T15:52:47.903+08:00RCP 编程记录RCP Perspective中View的布局<br />Perspective用于把一组任务相关的视图组合在一起提供给用户,其中有个区域叫做EditorArea,这个区域用于放置编辑器。<br />如果你的perspective无需编辑器,则可以通过pageLayout.setEditorAreaVisible(false);把编辑区域隐藏起来。这样,你的workspace就不会有一块灰色的区域了。<br /><br />如果想让两个view占据一个位置(如IPageLayout.RIGHT),在Perspective类中的createInitialLayout用如下方法:<br />IFolderLayout folder = layout.createFolder("messages", IPageLayout.RIGHT,<br /> 0.75f, IPageLayout.ID_EDITOR_AREA);<br /> folder.addPlaceholder(View1.ID + ":*");<br /> folder.addView(View1.ID);<br /> folder.addPlaceholder(View2.ID + ":*");<br /> folder.addView(View2.ID);<br /><br />要使得一开始view不可见,只当用户点击触发showView的时候才显示,可以如下:folder.addPlaceholder(View1.ID + ":*");<br />不要加上folder.addView(View1.ID)就可以了。<br />如果要使得Editor消失不可见,可以在Perspective类中的createInitialLayout加上一句,如下:<br />layout.setEditorAreaVisible(false);<br />如果要使得某个view不能关闭,可以在Perspective类中的createInitialLayout加上一句,如下:<br />layout.getViewLayout(View.ID).setCloseable(false);<br /><br /><br />TableListViewer的可编辑cell<br />按照一般的套路:设置tableviewer的columnProperties;设置CellEditors;设置CellModitifier;<br />其中实现ICellModitifier接口比较繁琐点。<br />最后值得注意的是:需要把ListTableView设置为SWT.FULL_SELECTION。否则,就必须单击两次,第一次表示选中,第二次表示编辑。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-47952398055577358062009-08-06T14:33:00.004+08:002009-08-06T14:40:07.750+08:00用spring构造bean的3种方法。1)直接构造<br />2)用静态工厂方法<br />3)<span style="font-weight: bold;">非静态</span>工厂方法。<br /><br />这是一段静态工厂方法的例子,向工厂方法传递参数使用constructor-arg。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-27916124116749459342009-08-06T13:22:00.002+08:002009-08-06T14:00:28.758+08:00类功能的分配开始写了个TclExecutor类。这个类可以执行tcl语句、tcl 文件。因为tcl interpreter是在这个类中创建的,interpreter是用一个线程在后台驱动的,所以我把TclExecutor当作资源类。是资源的东西,当然是要被管理的,否则就有资源泄漏的危险。所以,我就加入了结束tcl executor生命的方法disposeI(), disposeAll()。<br />因为要管理这些资源,又让TclExecutor的构造函数接受一个字符串当作executor的名字。以后就可以用名字来定位需要的executor。<br />为了定位,就需要一个管理类来管理这些executors。可以把这些管理executor的方法通通写到TclExecutor 中,也可以单独写一个manager类。<br /><br />当代码紧凑不是优点而是缺点时,就已经没有理由不把这些功能分别安排到不同的类中了。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-49706128380293303622009-08-01T15:13:00.001+08:002009-08-01T15:17:57.819+08:00setup svnserver for windows1)从http://subversion.tigris.org/ 下载svnserver.<br /><br />2)创建一个reaml svnadmin create E:\svn_repository\dahui<br /><br />3)在新的reaml下的conf目录中,配置密码及其它。<br />passwd文件:<br /> [users]<br /> admin = mypassword<br /><br />svnserver.conf文件:<br /> [general]<br /> anon-access = read<br /> auth-access = write<br /> password-db = passwd <br /> realm = goreaderAnonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-51601987159842486632009-07-21T15:05:00.000+08:002009-08-01T15:09:08.090+08:00clone 和copy/paste今天需要写一个copy/paste的功能。copy的动作执行以后得到都是data的reference。需要一个clone的动作。而以前的数据对象根本没有定义clone()。<br />可以总结一条了:当一个数据对象需要被copy/paste时,请准备好clone()方法。<br /><br />对于糟糕的遗留系统的补丁,我真的觉得是浪费生命。平时觉得稀松平常的原理,在这种系统面前凸显价值,但是,这种价值此时也只能成为教训了。<br /><br />今天还给诺西的同事show了一下如何用itcl写spirent testcenter的tcl。 如果当初他们写tcl之前好好建模,好好学习itcl,现在对新需求的应付应该是很轻松,很轻松了。<br /><br />一个项目的成功也许是因为技术的失败而失败。但是,归根结底是因为管理的失败而失败,决策的失败而失败,用人的失败而失败。<br />技术上的保障只是项目成功保障链条上的最后一环,前面的环节更具决定性。<br /><br />面向对象的方法是一种思考问题、解决问题的方法,不单纯的是一种语言。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-19720107802418453682009-07-16T16:24:00.002+08:002009-07-16T16:29:20.811+08:00技术平台断断续续地琢磨CLTF也好久了。今天再看Jelly,却发现有些需要的特性是Spring提供的,而在Jelly中不能获得。再一想,Jelly提供的最基本的功能,其实自己也可以比较容易的模拟出来。看来需要考虑使用一下Spring了。<br /><br />Groovy其实也应该是很好的。毕竟是解释型的,改动一起来应该很容易。<br /><br />最基本的技术选择,看上去简单,确实最具影响力的。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-24787597805163788892009-07-15T15:33:00.002+08:002009-07-15T15:59:17.152+08:00Object System for TCL下面这篇文章很好地讲述了用TCL语法模拟一个简单的Object system。<a href="http://users.telenet.be/koen.vandamme1/papers/tcl_objects/tcl_objects.html">http://users.telenet.be/koen.vandamme1/papers/tcl_objects/tcl_objects.html</a><br />对文章中的<span style="font-weight: bold;">“Object orientation is really just a way of thinking; it has more to do with design than with implementation.” </span>深有体会。<span style="font-weight: bold;"><br /><br /></span><a href="http://www.tcl.tk/about/oo.html">http://www.tcl.tk/about/oo.html</a><br />这是一篇关于object tcl情况的简单介绍。到tcl 8.6,TCL将内置一个object system了。<span style="font-weight: bold;"><br /><br /></span>目前存在的用于tcl的object system有:incr tcl, Snit, XoTcl .<span style="font-weight: bold;">..<br /><br />incr TCL的HomePage: <a href="http://incrtcl.sourceforge.net/itcl/">http://incrtcl.sourceforge.net/itcl/</a><br /><br /><br /></span>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-43568089165362030302009-06-25T17:16:00.003+08:002009-07-16T16:10:18.745+08:00Spirent testcenter 的基本模型。chassis就理解成一个基础设备,对应一个IP。<br />slot是设备上的一个插卡,其中有若干ports。<br /><br />每个port上有一个generator,用这个Generator可以发送多个StreamBlock.Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-55138038165230917562009-06-25T16:45:00.004+08:002009-06-25T17:14:23.049+08:00Something about tcl programming for Spirent TestCenter前两天为了解决遗留程序的一个bug,动手写了点TCL程序。<br /><br />TCL作为解释型的语言,并不在你第一次定义变量时给你预设一个值,哪怕是随机的值。所以,刚用起来有点不顺手。<br />TCL的数组其实很类似hashtable,tcl数组的index可以是任意值。所以,虽然tcl不支持多维数组,但是依旧有些小技巧模拟多维数组。这很重要,因为tcl同时没有structure类型。复杂的需要分层的数据结构只能依赖所模拟出来的多维数组了。<br /><br />如下的一段代码,就是用来模拟多维数组的:<br /> <code><br /> set trafficConfig($trafficHandle,Transmit_mode) $transmit_mode;<br /> set trafficConfig($trafficHandle,LoadUnit) $loadUnit;<br /> set trafficConfig($trafficHandle,FixedLoad) $loads;<br /> </code><br />需要注意的是,必须跟后面的字符串紧挨着。<br /><br />有了“多维”数组,再利用tcl的namespace eval 语句,就可以完成基本的数据结构的定义了。再写点函数,就可以模拟一个类了。<br /><code><br />package provide DataCenter 0.1<br /><br />set trafficConfig(NULL) NULL;<br /><br />namespace eval StcTools {<br /><br /> namespace eval Traffic {<br /> <br /> proc construct { trafficHandle transmit_mode loadUnit loads} {<br /> global trafficConfig;<br /> <br /> puts "Traffic construct() for $trafficHandle "<br /> <br /> set trafficConfig($trafficHandle,Name) $trafficHandle;<br /> set trafficConfig($trafficHandle,Transmit_mode) $transmit_mode;<br /> set trafficConfig($trafficHandle,LoadUnit) $loadUnit;<br /> set trafficConfig($trafficHandle,FixedLoad) $loads;<br /> }<br /> <br /> proc setting { trafficHandle name value } {<br /> global trafficConfig;<br /> set trafficConfig($trafficHandle,$name) $value;<br /> }<br /> <br /> proc printTrafficSettingInfo { } {<br /> global trafficConfig;<br /> puts "trafficSettingInfo:" <br /> foreach {key value} [array get trafficConfig] {<br /> puts " trafficConfig($key)= $value"; <br /> }<br /> }<br /></code> <br /><br />StcTools ::Traffic就可以理解为一个类。<br />construct()就是构造方法。<br />setting(handle, name, value)就可以理解为setter方法, 业务逻辑的方法就可以自己随便起名、定义了。<br /><br />用这种思路写出程序比遗留代码强多了---清晰。清晰了,当然就易维护。这种思路是从TCPMP项目中学来的。TCPMP利用C语言开发,但是它利用c的结构体,以及其它技术,也构造了自己的简单的面向对象架构。我都怀疑面向对象的初始想法可能就是基于这种简单的程序架构发展而来的了。<br /><br />程序开发中数据与逻辑的分离,数据层次的划分、组织,是很基本的事情。<br />数据的组织,又是直接和业务模型的抽象、建立相关的。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-61842594883598343512009-05-26T17:45:00.002+08:002009-06-25T17:15:18.413+08:00TestCenter TCL envSpirent's tcl env<br><br>pkgIndex.tcl 是包含在TestCenter的安装目录的:C:\Program Files\Spirent Communications\Spirent TestCenter 2.30\Spirent TestCenter Application<br><br>在pkgIndex.tcl文件中包含CTS_INSTALL_DIR,而这个变量并没有定义。<br>所以,如果想写tcl脚本使用TestCenter提供的API,就要设置环境变量CTS_INSTALL_DIR,并把CTS_INSTALL_DIR改为env(CTS_INSTALL_DIR).<br>比如:package ifneeded SpirentTestCenter 2.30 [list source [file join env(CTS_INSTALL_DIR) SpirentTestCenter.tcl]]<br>另一个,更好点的办法是在pkgIndex.tcl开始部分添加下面一行,:<br>set STC_INSTALL_DIR [pwd]<br><br><br>然后把TestCenter的安装目录添加到autopath:<br>lappend auto_path $env(CTS_INSTALL_DIR)<br>puts $auto_path<br><br><br>这样,按照Spirent_TestCenter_Automation_Conf_Prog_Guide.pdf的描述,就可以运行下面的代码了:<br><div style="margin-left: 40px;"><span style="background-color: rgb(217, 234, 211);">lappend auto_path $env(CTS_INSTALL_DIR)</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">puts $auto_path</span><br style="background-color: rgb(217, 234, 211);"><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">package require SpirentTestCenterConformance</span><br style="background-color: rgb(217, 234, 211);"><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set chassisAddress 172.18.101.31</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set slot1 10</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set slot2 9</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set port1 11</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set port2 12</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">puts "==== begin to create project"</span><br style="background-color: rgb(217, 234, 211);"><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set project [stc::create project]</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">puts "[ stc::get $project -children]\n"</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">set physicalChassisManager [stc::get system1 -children-physicalChassisManager]</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">puts "Connect to chassis...\n"</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">stc::connect $chassisAddress</span><br style="background-color: rgb(217, 234, 211);"><span style="background-color: rgb(217, 234, 211);">puts "==== connect ok."</span><br></div><br>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-64553123338633111742009-05-23T18:07:00.001+08:002009-05-23T18:07:29.917+08:00reference about tcl debug<br>总的一个reference. <a title="http://wiki.tcl.tk/8637" target="_blank" href="http://wiki.tcl.tk/8637" id="za7f">http://wiki.tcl.tk/8637</a><br><br>activestate关于开发工具的资源: <a title="http://www.activestate.com/tcl_dev_kit/" target="_blank" href="http://www.activestate.com/tcl_dev_kit/" id="w2gd">http://www.activestate.com/tcl_dev_kit/</a><br><br>一个免费的tcl debugger tool: <a title="http://gid.cimne.upc.es/RamDebugger/Ramdebugger_toc.html" target="_blank" href="http://gid.cimne.upc.es/RamDebugger/Ramdebugger_toc.html" id="r653">http://gid.cimne.upc.es/RamDebugger/Ramdebugger_toc.html</a><br><br>与eclpse的集成开发,不仅仅是TCL了,还有python, ruby,...: <a title="http://download.eclipse.org/technology/dltk/downloads/drops/R1.0/S-1.0RC1b-200905210941/" target="_blank" href="http://download.eclipse.org/technology/dltk/downloads/drops/R1.0/S-1.0RC1b-200905210941/" id="n_z7">http://download.eclipse.org/technology/dltk/downloads/drops/R1.0/S-1.0RC1b-200905210941/</a><br>Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-5173759756995140902009-05-14T09:07:00.002+08:002009-05-14T10:39:22.501+08:00Eclipse's CheckboxCellEditor项目中需要把表格中的某列用checkbox表示出来,按照《eclipse从入门到精通》中的步骤没有弄出来。<br />这是eclipse celleditor的一些samples: <a href="http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet009CellEditors">http://wiki.eclipse.org/index.php/JFaceSnippets#Snippet009CellEditors</a><br /><br />TableViewerColumn TableColumn的区别?<br />TableViewerColumn .getColumn() 返回的是TableColumn对象。什么时候该用哪个呢?<br /><br />尝试,ComboBoxCellEditor, 发现EditingSupport子类的getValue()需要返回Integer类型。CheckboxCellEditor则需要返回Boolean类型。<br />跟踪到CheckboxCellEditor的 <br />protected Control createControl(Composite parent) {<br /> return null;<br />},发现它根本没有实现。所以,CheckboxCellEditor是根本不能使用的。需要你继承它来完成这个方法。真是奇怪eclipse为什么不提供个实现呢?<br /><br />最后发现了一个类似于CheckboxCellEditor的实现BooleanCellEditor: <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java?view=markup">http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/BooleanCellEditor.java?view=markup</a> 但是,BooleanCellEditor需要运行在eclipse3.4。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-79014123541858826062009-05-12T16:31:00.004+08:002009-05-12T16:49:48.120+08:00和Martin交流Martin告诉我:<br /><span style="color: rgb(51, 102, 102);">解除依赖环在大型项目开发中尤其重要。否则, 你做好了,我改了一点东西后,就又坏了. </span><br /><span style="color: rgb(51, 102, 102);">你改好之后, 我又不能编译了,故在大项目中不能存在依赖环,只能存在<span style="font-weight: bold;">树状依赖</span>. 中间没有环.</span><br /><br /><br />dahui said:<br />我以前一直觉得业务不是很重要,现在我觉得业务是基础,是你能够建立正确model的基础。<br /><br />福祥 says:<br />有两个领域,一个是软件,一个domain.<br /><br />dahui says:<br />我还在看domain drived development. 很多观点我都很认同。<br />其中也提到了敏捷开发的缺陷。 我也深有感触。<br />你想过没有为什么开始流行敏捷?<br /><br />福祥 says:<br />CMM太繁琐,<br />并且中间件出现,<br />可以总结出一些模式.<br /><br />dahui says:<br />我觉得是因为程序员的水平普遍提高了,程序员都有了一定的(甚至不错的)设计能力。有些分工就可以不那么明确了。 以前是系统分析员、设计员做的工作,分配到了程序员手里。<br />其实,这不一定适合所有项目、不适合所有项目组。<br /><br />福祥 says:<br />?<br /><br />dahui says:<br />一定要根据具体情况来开发。<br />说到底,还是跟人有关。 如果一个项目组没有“高人”,或是没把“高人”放在合适的位置上,不管你项目用CMMI还是agile,都不会成功的。我现在还是看重人的作用。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0tag:blogger.com,1999:blog-1342129713710652180.post-7141972498858734192009-05-12T15:55:00.002+08:002009-05-12T16:06:21.581+08:00利用inferface切断依赖背景:<br />存在模块A、模块B,其中A是common的,发现有些B中的class BClass应该移到A中。<br />当把BClass 移到模块A中后发现,BClass的有些方法依赖于模块B中的一个类BbClass。而BbClass又跟模块B中许多其它类强烈耦合。<br /><br />问题:<br />总不能把所有依赖的东西都move到模块A中呀!<br /><br />解决:<br />1)根据BbClass,抽象出一个接口(或抽象类)--比如叫做IBClass,这个接口要定义在模块A中。<br />2)让BbClass实现IBClass。<br />3)修改模块A中对BbClass的调用接口为对IBClass的调用。Anonymoushttp://www.blogger.com/profile/11115414503554806194noreply@blogger.com0