Magento with python connect

近期一直在接触Magento这个PHP的商贸平台。非常强大的后台,同时也带来了非产大的维护量。好像我这种已经被Python污染到简单至上的人,用起来,绝对是噩梦。找到了一个非常好的支持库:python-magento: https://github.com/zikzakmedia/python-magento这个库本身是为了对接OpenERP开发的,顺手借用,觉得非常适合来作为后台支持。毕竟社区版的Magento后台功能非常有限。

<span title='2013-08-22 07:29:00 +0000 UTC'>2013/08/22 Aug</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;2 words&nbsp;·&nbsp;map[name:SCys uri:]

sqlalchemy relationship实例添加顺序

近来一直埋头到python的编程中。用到了sqlalchemy这个库,记录下以下一个案例。定义两个Model类class A(Model): … child = relationship(‘B’, backref=‘parent’)class B(Model): … a_id = Column(…, ForeignKey(A.id))然后我们要将B实例添加到A实例child中,正确的做法是,先读取A实例到会话中后操作B实例:»> a = A.query.filter(…).first()»> b = B() or B.query.filter(…).first()»> a.child.append(b)»> db.session.commit() OK这样是没有问题,当然留意,让建立B后再读取A实例到会话,提交的时候会提示A实例已经有变化的错误,如下:»> b = B() or B.query.filter(…).first()»> a = A.query.filter(…).first()»> a.child.append(b)»> db.session.commit() ObjectDereferencedError: Can’t emit change event for attribute ‘A.child’ - parent object of type has been garbage collected

<span title='2013-02-11 02:29:00 +0000 UTC'>2013/02/11 Feb</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;51 words&nbsp;·&nbsp;map[name:SCys uri:]

OpenVPN Client in Windows

拥有一个OpenVPN的认证帐号或者个人证书;2. 下载一个Windows客户端:http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe3. 安装客户端4. 编写合格的配置文件:xxxx.ovpn,内容(因应你的服务器来变化):clientdev tap2proto udptls-clientnobindca /etc/openvpn/keys/ca.crtcert /etc/openvpn/keys/single.crtkey /etc/openvpn/keys/single.keycomp-lzopersist-keypersist-tun# 需要的route# route 192.168.0.0 255.255.0.0 192.168.252.254remote [VPN 服务器地址] [VPN 服务器端口]5. 最后点击右下角的图表,选择你刚才配置,启动VPN客户端吧。

<span title='2012-12-16 19:53:00 +0000 UTC'>2012/12/16 Dec</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;19 words&nbsp;·&nbsp;map[name:SCys uri:]

Bind9 Dynamic DNS

Dyndns is so nice!1.KeyGen:#dnssec-keygen -a HMAC-MD5 -b 128 -n HOST ddns-keyKddns-key.+157+17069.keyKddns-key.+157+17069.private2.Configure bind name.conf.local. add blow lines:key ddns-key { algorithm HMAC-MD5.SIG-ALG.REG.INT; secret “[key in public file]”;};zone “example.com” { … allow-update { key ddns-key; };};3.Use public key to update zone filensupdate -v << EOFserver ns1.example.comkey ddns-key [key in public file]zone example.com.update delete test.example.com. 300 Aupdate add test.example.com. 300 A 192.168.0.22showsendEOF

<span title='2012-12-15 01:29:00 +0000 UTC'>2012/12/15 Dec</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;58 words&nbsp;·&nbsp;map[name:SCys uri:]

simulate www browser with python

Simulate www browser with python. So easy with these libraries: spynner: base on libQtNetwork splinter: base on selenium WebDriver but not stable. Spynner: #!/usr/bin/python # -*- coding: utf-8 -*- import spynner import pyquery browser = spynner.Browser(debug_level=spynner.INFO) browser.create_webview() browser.show() browser.load('http://www.wordreference.com') browser.load_jquery(True) browser.choose('input[name=lr=lang_es]') browser.click('input[name=enit]') browser.click('a[class=l]:first') d = pyquery.PyQuery(browser.html) d.make_links_absolute(base_url=browser.url) href = d('a:last').attr('href') print href print len(browser.download(href)) browser.browse() Splinter install splinter: easy_install splinter install depend google chrome or firefox; install depend webdriver google chrome server wrap, download some package in https://code....

<span title='2012-11-30 22:23:00 +0000 UTC'>2012/11/30 Nov</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;145 words&nbsp;·&nbsp;map[name:SCys uri:]