english
Dec 21, 2011
Plone SEO? collective.perseo!
The package collective.perseo has just been released. collective.perseo is a package for Search Engine Optimization and offers several kind of SEO features
why collective.perseo?
collective.perseo was born during a collaboration with Irene Capatti, Federica D'Elia and SEO Specialist Andrea Pernici. The product quintagroup.seoptimaizer is very useful, but Andrea needed something more.
Features
With collective.perseo you can manage:
-
globally (configurations applied to each page of the site), through “PerSEO” tool under Add-on Configuration:
-
Webmaster Tools (Google Webmaster Tools, Yahoo Site Explorer, Bing Webmaster Tools)
-
tag title, description and keywords meta tags, separately for:
-
Disable the indexing of resources using noindex and nofollow, separately for:
-
Search page
-
Login and Registration pages
-
Administration pages
-
Single pages
-
Event
-
File
-
Folder
-
Image
-
Link
-
News Item
-
Topic
-
(also handle noodp, noydir, noarchive, nosnippet)
-
-
Content types included in the sitemap.xml.gz

-
Ping sites (Google, Bing, Ask) automatically when the Site Map is updated
-
Indexing RSS feeds
-
Add itemscope and itemtype attributes to body tag (if you install the extension collective.perseoschema for Schema.org)
-
-
one by one, through “SEO” tab on each content of the site (allows you to change SEO settings for that specific content):
-
tag title and description and Keywords meta tags
-
Meta Robots Follow Tag (follow/nofollow)
-
Meta Robots Index Tag (index/noindex)
-
Meta Robots Advanced Tag (noodp, noydir, noarchive, nosnippet)
-
Canonical URL
-
Content included in the sitemap.xml.gz (yes/no).
-
Priority of content in sitemap.xml.gz
-
itemtype attribute (if you install the extension collective.perseoschema for Schema.org)
-

Useful links
http://pypi.python.org/pypi/collective.perseo
http://pypi.python.org/pypi/collective.perseoschema
Dec 06, 2011
SSH tips and tricks: how to save time configuring properly SSH
This blog post is about ssh client configuration. Configuring ssh is a really good practice both for saving time and keeping organized your connections data. Even though the blogosphere is full of posts like this, I think it is worth repeating because the practice of keeping an up to date ssh configuration is not so diffused.
In my daily activity I find myself connecting to a lot of servers and it is hard to remember for each of them the correct hostname or IP and the related credentials.
To speed up my work I try to keep has much as possible updated my .ssh/config file.
Let's say, for example that one of our clients, let's say ACME :), gives us access to a fictitious server with the IP address 999.999.999.999.
They give us the access that server with the username bugs and ssh is listen to port 2222.
As soon as I am authorized to connect to a new server I insert a new section to the file like this:
# The new acme server Host acme HostName 999.999.999.999 Port 2222 User bugs
This way instead of typing:
ssh -p2222 bugs@999.999.999.999
I can just type:
ssh acme
with the same effects.
The benefits of that go beyond the use of ssh, because the same configuration file has effect on other ssh related programs like scp, rsync and sshfs.
In addition .ssh/config is parsed by bash completion scripts so I can save further keystrokes (holy laziness)!
This is good, more than for today, for tomorrow because time passes and I can forget the username, the server IP or the port, but I would hardly forget I worked for ACME and to get those info quickly reading .ssh/config is enough.
Of course I can add many hosts sections to the .ssh/config like I am showing in this example:
## List of ACME servers ## # The staging server Host acme-staging HostName staging.example.com User bugs # The production server Host acme-production HostName production.example.com User bunny ## Another customer ## Host demo HostName 10.0.1.100 User donald # I can also setup a tunnel to a port Host demo-debug HostName 10.0.1.100 User root LocalForward 8080 localhost:8080
As you can see each section starts with the Host declaration and the settings are effective only for that specific Host.
In the last example we make a tunnel forwarding the 8080 port to localhost, useful in case the server firewall filters direct connections from outside.
With this configuration the command:
ssh demo-debug
is equivalent to:
ssh root@10.0.1.100 -L 8080:localhost:8080
Further readings
Beyond the nice manual page about ssh configuration:
man ssh_config
you could find very useful those links to
A note to KDE users
I found out that also sftp and fish KIO slaves are aware of ssh configuration, with the difference that fish overrides the User directive, i.e., using the example before, to connect to the acme server as bugs I have to point dolphin to either fish://bugs@acme or to sftp://acme.
Nov 04, 2011
Say hi to Android
A brief introduction to Android for developers
In the last months, I have been looking for an opportunity to get into the Android world.
Finally, after a while I got the right one: porting an iPhone app to Android platform.
The application is quite simple because it doesn't involve anything far from a common web application: it just retrieves information about events from a web service.
If you make a list of performed tasks, it would look like this:
- retrieving the xml content
- parsing the xml
- storing a few configuration files
- loading images
- building a couple of data structures
- showing everything using the specific views and widgets
Thanks to the reference documents and materials found in the Internet, I got a demo app smiling on my device in a couple of days (not a proper relase, but it could run smoothly).
If you are familiar with Eclipse, you will appreciate the effort made by Google, in order to provide a confortable developement environment. Let's see why.
From the official site you can download:
- Android SDK (JDK required)
- Android Development Tools (ADT) Plugin
You just need to set your SDK. And that's all! Ready to start.
As you can easily guess, the default API provided by Google is Java-based.
I know that some of you can argue "Java is not the best choice", but it's solid and well known by most programmers. It is also well documented and it comes with tons of libraries.
The Android application layout is done by a bunch of xml files. The ADT provides a nice interface to manage them.
All the Java code needed for your app can be taken from your personal toolset or grabbed from the net.
What I love most, is that you can easily connect your device and directly deploy the application on it. Moreover, for those who make use of remote debugging in Java, Android (DDMS) is faster and simpler then ever: just press the debug button and your code will be ready for debugging from your android device. Nothing new to the world, but as I said easier then I thought.
A small disadvantage if you use the virtual device (AVD), because it is really slow, especially in loading.
Just a small consideration: because the hardware behind a mobile device is usually less powerful then a standard pc, you have to be careful.
In a few days the release of AppEventi for Android will be ready. http://www.ferraraterraeacqua.it/
Here is the iPhone app: http://itunes.apple.com/en/app/ferrara-eventi/id449817238?mt=8
Oct 31, 2011
Plone at PyCon UA
I spent last weekend (22-23 October) in Kiev promoting Plone and Pyramid at PyCon UA. It was an amazing opportunity to spread the latest news about Plone4 and its enhancements.
The Kiev event was fruitful experience from two points of view: the audience was not aware of what has been happening in Plone since 3.x; they were mostly Django developers. I think I did my best to explain what are the key values of using Plone and Pyramid together and what are the benefits comparing to other frameworks like Django. I met several fantastic guys deeply interested in what we are doing in both Plone and Pyramid community. Hope to see you all on another Python event.
Apart of Plone talk there were other invited speakers. Let me mention few of them.
Opening talk done by Tarek was about Packaging. He explained current situation of packaging in Python and the future of it. I hope we will have setup.cfg to rull-them-all in near future and that the community will start to use proper versioning soon.
Then there was Armin with Basket of Random Python Snippets. I don't like the idea of showing ONLY code while doing your presentation but I strongly encourage you to read them online. Some of them are really great tips!
Last talk I attended was done by Alexander and I must admit - I have enjoyed it a lot. He was showing "SQLAlchemy: a better ORM". I was never a big fun of Django ORM but now I'm strongly convinced that Pyramid + SQLAlchemy + pyramid_formalchemy is a way much easier to play with.
Bottom line: I must agree with Yury that it would be more interesting event if all of the speakers present slides in English (like on RuPy2011 last October). Nevertheless I enjoy this weekend a lot. I love the city and the atmosphere. The topics and invited speakers were properly chosen so everybody could find a subject to discuss about. Thanks again and hopefully see you next year.
And tomorrow it is time for Plone Conference 2011 which will end this autumn's conference marathon.
Oct 28, 2011
Using JavaMail with TLS
Snippets about sending mail though Java with TLS support
Here is an example to show you how to use JavaMail API method to send an email, using both TLS and SSL connection.
If you are using TLS, remember to disable this property:
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.starttls.enable","true")
props.put("mail.smtp.host", server);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
props.put("mail.debug","false");
props.put("mail.smtp.port",port);
props.put("mail.smtp.ssl.enable","true");
props.put("mail.smtp.socketFactory.port", port);
props.put("mail.smtp.socketFactory.fallback", "false");
Remember that, when you set Authentication to server with PasswordAuthentication class, you could experience this error:
"javax.mail.AuthenticationFailedException: 535-5.7.1 Username and Password not accepted."
Send by server if user or password used for authentication failed. Usually means that server requires full user name (user@server.com) to be used.
Oct 20, 2011
RuPy 2011 - Strongly Dynamic Conference
Last weekend (14-16 Oct 2011) I've attended RuPy (Ruby + Python), a strongly dynamic conference held in Poznań (Poland) and organized by GIK Association. I had a great opportunity to share RedTurtle's "Pyramid and Plone" integration use case with wider audience. It was truly an open source event and a great opportunity to meet geeks from the Ruby community.
It was RuPy's
3rd 4th edition and apart it was the biggest (ca. 300 attendees) I must say - it was the best (I was attending all previous editions). The GIK have chosen Poznań International Fairs as the conference venue which was a damn good idea. During 3 days of the conference there was ca. 30 events (talks, workshops and sprints). Most of them was related to Ruby which is a problem each year. Getting more support from Python community is highly appreciated!
What I think is notable is the speaker feedback system. Each room had 3 containers marked: :-) :-| and :-(. After each session the speaker was receiving his anonymous feedback from the audience. From the speaker point of view (so also mine) it's surprisingly easy and gives you great opportunity to check if what you've just said wasn't a completely bullshit. What I would suggest is to make bigger effort in promoting it after each talk.
Interesting talks
my subjective list of notable talks
Programmer Anarchy
by Fred George
Writing your own programming language
by José Valim
Tradeoffs and Choices: Why Ruby Isn't Python
by Yehuda Katz
I didn't find the slides but I hope RuPy team will publish them soon. In the mean time - short abstract:
"When a Pythonista first dives into Ruby, he is confronted with a strange and unusual world. Multiple kinds of functions, implicitness everywhere, violations of the Zen of Python galore! In this talk, Yehuda will talk about the tradeoffs in Ruby's language design: why, in many ways, Ruby couldn't be more like Python even if it wanted to."
Summary
It was an amazing weekend with some interesting discussions with people from Python and Ruby world. Thanks RuPy, hope to see you next year!
Last but not least the organization committee followed best practices and shared their website source code to wide public.
Sep 15, 2011
Rendering of HTML using innerHTML or .update() method with Javascript
By manipulating an element's innerHtml you'll be able to change your text and HTML as much as you like. But, pay attention!!!
These methods are very useful if you want to pupulate div's in your page, but at the end rendering would be strange.
Problem is that HTML that you produce in some way (e.g. agents in Lotus Domino) must be well-formatted and valid before you put it into your <div>
For example, if you want to put an image and you write:
<img src="<somePath>" alt="" border=0 />
instead of
<img src="<somePath>" alt="" border="0" />
Same behaviour if HTML TAG are not correctly nested.
Jul 19, 2011
Problems with charset in 8.5.1 environment
Strange behaviour managing XML file in Java agent
In this scenario, i've experienced some problems with UTF-8 charset in strings. In 6.5 environment everithing works fine.
This is my code in a Java agent:
org.w3c.dom.Document docXML = attachSegnatura.parseXML(false); XSLTResultTarget out = new XSLTResultTarget(); out.setFileName(path + "SegnaturaRT.xml"); attachSegnatura.transformXML(xsl, out); DOMParser parser = new DOMParser(); parser.parse(path + "SegnaturaRT.xml"); org.w3c.dom.Document docRT = ((DOMParser)parser).getDocument();
tFactory = TransformerFactory.newInstance(); StreamSource xslSS = new StreamSource(pathFile+"Segnatura.xsl"); StreamSource xslRT= new StreamSource(pathFile + "Segnatura.xml"); FileOutputStream fos = new FileOutputStream(pathFile + "SegnaturaRT.xml"); transformer = tFactory.newTransformer(xslSS); transformer.transform(xslRT, new StreamResult(fos)); transformer.reset(); fos.close(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); docRT = dBuilder.parse(new File(pathFile + "SegnaturaRT.xml"));
Anybody experienced something like this?
Jun 29, 2011
Europython 2011: aftermath
Want to get rich? Create a methodology. Want to write better programs? Go to EuroPython!
It has been a tiring but exciting week in Florence.
After four years of national PyCon Italy, the team has been excellent and set up an event that clearly shows the level of maturity of the community.
Over the years since the first EuroPython conference, the big change is that we don't have to justify our language choice anymore.
Actually, I would not even be a programmer it where was no Python. I was a system administrator, more like a plumber than an internal decorator.
Python has taken me by hand, teaching and letting me write things I would not have attempted in other languages available at the time.
As programmers, we make trade-offs and take compromises several times per day, while we design and write applications.
Very often we take a different road than we did the day before, because we've seen what lays ahead and want to avoid it, or the customer has changed his mind, or we have a better understanding of the whole.
As a matter of fact the right answer to a programming question is often "it depends", because the architectures, markets and business models are getting more and more complex, and we as software craftsmen have none of the certainties than mathematicians or computer science people take for granted.
Fortunately for us and our customers, software can be easily changed, and nothing prevents experimenting with different approaches if time allows.
But once in a while - typically at the start of a development cycle - we have bigger choices, the decisions that make room for the following ones: the basic architecture.
- What language(s) are we going to use? (that's easy, Python. but it depends)
- Light framework or a heavy, full featured one?
- Relational or non-relational database? And if non-relational, which of the many?
- Is our application process or data driven, or both? (this is vague. it's usually both)
- Browser or server side processing?
- How will it scale to many concurrent users?
and so on, and on.
At this point, if we pick the wrong road, the application could still be delivered, hopefully in time and the customer will be happy (at first), but the program itself might be a lot more complicated than it needs to be, and hard to change. The price will be paid over time, as new needs come and maintenance is required.
Unfortunately for us, some of these are hard questions, also subject of fashions and marker pressure, and it is very hard to have a comprehensive picture just by following technical blogs.
That's why I long for conferences like EuroPython, where the scope of the talks is as wide as can be, while still remaining highly technical.
Where the authors are ready to discuss about it over the lunch, and everybody is smart for having chosen Python :-)
Best talks.. ever :-)
A few of the talks tackling old problems in light of new tools and experiences:
Relate or !Relate (Mark Ramm-Christensen)
Mark explains the difference between the forest of NoSQL databases, and shows that a good SQL DBMS can scale surprisingly well.
This is a dear topic to me, because direct approaches in one side require complex contraptions on the other one, and vice-versa.
As a side note, lately the MySQL - Postgres debate seems to be over. The latter one has sharply won, if not the market, the minds of the programmers.
How to build complex web applications having fun? (Andrew Mleczko)
If the user wants both, give them both. Instead of fitting every requirement in a single architecture, try deploying a full-featured
CMS along with a light, flexible framework and divide the tasks -- a little like loading a bike on your camper.
You can go anywhere and they integrate well.
This is easier today (in the post-WSGI world) thanks to Pyramid, a highly refined foundation for web applications that lets a lot
of freedom: should the architecture be modeled after Zope, Plone, Pylons, Turbogears, Rails or Django? With Pyramid, "it depends" is the main concept :)
Other worth mentioning
- Challenges in developing a large Django site (Simon Willison)
- An iPhone-Python love affair: Building APIs for mobile (Anna Callahan - Nate Aune)
I also had fun with Raymond Hettinger, the only developer I've known that adds a +1 charisma bonus within a 10mt radius.
In his training track, he tore apart core concepts of Python (classes, decorators, properties, descriptors, dictionaries) and as he spoke rebuilt them using lists only. MacGyver couldn't do better!
But really, I could list half of the talks in the schedule, they are that good, and they kept a good balance of more and less advanced matters.
and the plone-ish stuff?
Sure, I would have liked a few more talks about Zope, Plone, BlueBream or Grok, especially highlighting how they have changed in the latest years, becoming more powerful, easier to extend and deploy, and there should be some effort communicating that to new developers.
They are coming to the conference to look for directions, and might go after some fashionable, but less capable tools.
Jun 20, 2011
Pyramid CRUD sprint summary
Pyramid CRUD sprint is over. It was an amazing event thanks to Gaël Pasgrimaud and Patrick Gerken. We have been sprinting in Redturtle's office to improve pyramid_formalchemy and fa.jquery. We have archived most of the sprint goals!
Patrick was working on the first two tasks:
PASTER TEMPLATE
It can be used to add a skeleton to an existing project or to create a new project. If you create a new project, you must first install pyramid_formalchemy in your python environment, either with pip:
$ pip install pyramid_formalchemy
or with easy_install:
$ easy_install pyramid_formalchemy
Only after that, the paster template becomes available. The template was made with the idea that it can be used to extend existing applications. It does not create an app for you. The provided template works well with pyramid_alchemy, pyramid_routesalchemy and akhet. To bootstrap an application, call paster like that:
$ paster create -t akhet -t pyramid_fa myapp
The application is created by akhet, akhet does not know about pyramid_formalchemy, and pyramid_formalchemy cannot modify the app configuration. So you have to do this by hand. First, you must add the install dependency like explained earlier. Second, you must add the following line in the main method that returns the wsgi app, directly after Configurator has been created (The example assumes that the Configurator instance is stored under the name “config”):
... config.include(myapp.fainit) ...
To add the minimum configuration to an existing application, you should be able to run:
$ paster create -t pyramid_fa myapp
All files that paster creates are prefixed with fa, and should not interfere with existing code.
FANSTATIC
Patrick's second task was fanstatic integration. Fanstatic is a small but powerful framework for the automatic publication of resources on a web page. Think Javascript and CSS. It just serves static content, but it does it really well. Integrating it with fa.jquery was a time consuming task but we managed to get a working proof of concept. I will blog more details when we publish something stable.
Next tasks were handled by Gaël:
CUSTOMISABLE ACTIONS
Action are basically links or input button. By default there is only one category buttons which are the forms buttons but you can add some categories like this:
>>> from pyramid_formalchemy.views import ModelView
>>> from pyramid_formalchemy import actions
>>> class MyView(ModelView):
... actions_categories = ('buttons', 'custom_actions')
... defaults_actions = actions.defaults_actions.copy()
... defaults_actions.update(edit_custom_actions=Actions())
Where myactions is an Actions instance
You can also customize the actions per Model:
>>> from sqlalchemy import Column, Integer >>> from sqlalchemy.ext.declarative import declarative_base >>> Base = declarative_base() >>> class MyArticle(Base): ... __tablename__ = 'myarticles' ... edit_buttons = Actions() ... id = Column(Integer, primary_key=True)
The available actions are: listing, new, edit
But you can add your own:
>>> from pyramid_formalchemy.views import ModelView >>> from pyramid_formalchemy import actions >>> class MyView(ModelView): ... actions.action() ... def extra(self): ... # do your stuff ... return self.render(**kw)
I18N
Yes, pyramid_formalchemy is now i18n! You need to add to your pipeline:
[app:pyramid] ... default_locale_name = en available_languages = fr en
and that's it! Right now we have english and french translations but others are coming.
I was working on the first three tasks:
View customization
This was one of the main sprint tasks - to have a possibility to customize CRUD views per model. You can register them simply like that:
config.formalchemy_model_view('admin',
model='pyramidapp.models.Foo',
context='pyramid_formalchemy.resources.ModelListing',
renderer='templates/foolisting.pt',
attr='listing',
request_method='GET',
permission='view')
and per Model:
config.formalchemy_model_view('admin',
model='pyramidapp.models.Foo',
context='pyramid_formalchemy.resources.Model',
name='',
renderer='templates/fooshow.pt',
attr='show',
request_method='GET',
permission='view')
formalchemy_model_view is an extension for config.add_view so you can use all view specific kwargs.
Widgets
We were able to finish simple implementation of autocomplete widget. It's not yet fully documented but it will be released in pyramid_formalchemy 0.4. Here is how you use it:
from pyramid_formalchemy.renderers import pyramid_autocomplete User.group.set(renderer=pyramid_autocomplete(filter_by='name'))
where User is your fieldset and group is your relation field; filter_by parameter is the SQLAlchemy column you want to filter (autocomplete) on.
Events hooks
We have provided four events:
- IBeforeValidateEvent
- IAfterSyncEvent
- IBeforeDeleteEvent
- IBeforeRenderEvent
There are also two more specific render evnts:
- IBeforeShowRenderEvent
- IBeforeEditRenderEvent
You can use pyramid_formalchemy.events.subscriber decorator to use them:
from pyramid_formalchemy import events from pyramidapp.models import Foo @events.subscriber([Foo, events.IBeforeValidateEvent]) def before_foo_validate(context, event): #do your stuff here
Summary
It was a very productive four days. Thanks again for all your help. We should release new versions of pyramid_formalchemy and fa.jquery in the following days. If you don't want to wait - grab the development versions on github.
You can find more sprint photos here - http://www.flickr.com/photos/tags/crudsprint2011


