Personal tools
You are here: Home Authors federicadelia

Federica D'Elia

Mar 28, 2012

Traning with Jarn: Much more than training!

Filed Under:

We recently took a training, done by the Jarn guys, Denys and Yiorgis. It was a very important experience to me: it changed my perspective

I liked the enthusiasm of Denys Mishunov. He gave us many suggestions, tips and tricks that we needed to improve our daily work. This is the most important thing to me.Thanks to Jarn guys, I discovered the importance of enjoying my work. These tools can really make us work more quickly and easily, and make it more fun.

I liked so much Yiorgis Gozadinos approach: he is always looking for the cleanest and simplest way to solve problems. For example, we talked about the importance to follow Design Patterns, reusable solutions that can be applied to commonly occurring problems. This patterns lead you to result, with a lower effort and no waste of time. 

Passion and enthusiasm shown by my teachers made me once more realize that the best way to reach professional growth is loving what you do.

Jarn CourseAmong the many other topics we discussed during training, we spoke about tests, that allow you to increase your work quality.

Besides learning useful and interesting tools, we also made a comparison between our and their way of working. In some cases, we found most effective approaches.

Jarn Course

Thank you, Jarn guys, not only for what you taught us on a technical level, but also for the emotional charge you gave me!

 

 

Dec 21, 2011

Plone SEO? collective.perseo!

Filed Under:

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

New package for Search Engine Optimization (SEO)

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:

      • Home page

      • Single pagePerSEO title

      • Search page

      • Not Found page

      • Author page

      • Site Map page

      • Contact page

      • Event

      • File

      • Folder

      • Image

      • Link

      • News Item

      • Topic

    • 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.gzPerSEO site map

    • 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)

PerSEO tab

Useful links

http://pypi.python.org/pypi/collective.perseo

http://pypi.python.org/pypi/collective.perseoschema

http://plone.org/products/collective.perseo

http://plone.org/products/collective.perseoschema

Nov 18, 2011

Modulistica PDF online: popolamento automatico via Python

Filed Under:

Un suggerimento per aggiungere testo a un file pdf comune, come ad esempio un banale modulo del censimento, utilizzando alcune delle librerie Python in circolazione

La creazione di pdf è spesso richiesta quando si sviluppa un'applicazione. Ma ci dobbiamo destreggiare in un mare di librerie Python

Per lo sviluppo di un'applicazione mi sono trovata a dover generare un pdf il cui contenuto consiste in un modulo, ad esempio il modulo del censimento, compilato con i dati degli utenti dell'applicazione presi run-time dal sistema.

Avrei impiegato troppo tempo a disegnare il modulo insieme ai dati dell'utente, in più, per certi moduli (come il modulo censimento) sono già forniti i pdf.

Pensare di caricare il modulo come immagine di sfondo non è fattibile. Prima di tutto per la qualità scarsa del pdf finale e poi perché le dimensioni del file di output aumentano molto a causa dell'immagine usata come sfondo.

Il file da ottenere è un modulo già fornito in versione pdf, ma a cui ho bisogno di aggiungere testo.

La soluzione, a mio avviso migliore, è stata quella di usare ReportLab per disegnare un pdf fatto unicamente dei dati dell'utente per poi fare un merge del primo con il pdf contente il modulo, usando PyPDF.

L'unica difficoltà in questo approccio è creare il pdf contenente i dati di riempimento. Infatti questi dati devono essere nella posizione giusta, prioprio come se stessimo compilando il modulo.

La soluzione è: merge e righello alla mano

Per superare questo ostacolo agilmente ho usato uno screen ruler. Io ho preferito "Free Ruler" per Mac OS X tra i vari righelli che ho trovato in rete, soprattutto per il suo tick mark interattivo che permette di fare una misura abbastanza accurata.

Ho aperto il pdf con il modulo da compilare, e poi ho misurato con il righello i punti in cui inserire i dati. Per creare il pdf con i dati di riempimento ho usato ReportLab che consente di scrivere stringhe di testo in un punto esatto, utilizzando le coordinate x e y.

Ecco la MIA ricetta

Passo 1

Aprire il pdf che rappresenta la base del nostro impasto, ovvero  il modulo da compilare, usando la classe PdfFileReader di pyPdf.

import codecs
from pyPdf import PdfFileWriter, PdfFileReader

input1 = PdfFileReader(codecs.open(path_modello_censimento, "rb"))

 

Passo 2

Preparare il pdf con i nostri canditi: i dati di riempimento. Qui entra in gioco ReportLab.

import StringIO
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm

packet = StringIO.StringIO()
can = canvas.Canvas(packet)
...
textobject = can.beginText()
textobject.setTextOrigin( 11.94*cm, 20.12*cm)
textobject.textLine('hello world')
...
can.drawText(textobject)
can.showPage()
can.save()
packet.seek(0)

Come unità ho usato i centrimenti, sia nel fissare l'origine di ogni striga di testo inserita, sia quando ho misurato con il righello. 11.94 e 20.12 sono due esempi di coordinate.

Tenere presente che l'orgine si trova in basso a sinistra. Ma con l'istruzione seguente possiamo spostare l'orgine in alto.

can.translate(cm, cm)

 

Passo 3

Aprire il pdf creato sopra con PdfFileReader.

input2 = PdfFileReader(packet)

 

Passo 4

Aprire il pdf finale, che conterrà il merge dei due pdf precedenti con la classe PdfFileWriter di pyPdf.

output = PdfFileWriter()

 

Passo 5

Adesso la parte più divertente: "Impastare".

page0 = input1.getPage(0)
page0.mergePage(input2.getPage(0))
output.addPage(page0)

Dopo aver unito i due pdf pagina per pagina si arriva finalment al punto 6..

Passo 6

Adesso abbiamo il nostra risultato finale "output" che può essere memorizzato ovunque si voglia, io lo scrivo in un file temporaneo per completare l'esempio:

import tempfile
temp_file_name = tempfile.mktemp()
outputStream = codecs.open(temp_file_name, mode="wb")
output.write(outputStream)
outputStream.close()
os.unlink(temp_file_name)

 

L'elaborazione richiede un po' di tempo, ma il risultato finale è buono. Buon appetito!

Apr 13, 2010

GDIP: Integration of Google Docs services in Plone

Filed Under:

Packages for integration of Google Docs services in Plone were released on pypi and on plone.org

The purpose of GDIP is to provide the Google Docs services to Plone users.

Advantages:

  • Plone users can save their files on Google servers, instead of in the ZODB;

  • Plone users have multiple access points to your files: they can manage their documents using two systems: Plone and Google Docs;

  • Plone users can edit their documents directly from the Google Docs application, embedding that page in the current window of the Plone application;

The products collective.googleauthentication, collective.googlesystemstorage, collective.googlesharing and collective.googlemodifycontent provide the integration of Google Docs services in Plone.

Packages were released on pypi:

http://pypi.python.org/pypi/collective.googleauthentication

http://pypi.python.org/pypi/collective.googlesystemstorage

http://pypi.python.org/pypi/collective.googlesharing

http://pypi.python.org/pypi/collective.googlemodifycontent

and on plone.org:

http://plone.org/products/collective.googleauthentication

http://plone.org/products/collective.googlesystemstorage

http://plone.org/products/collective.googlesharing

http://plone.org/products/collective.googlemodifycontent

 

The system integrates Google Docs services in Plone using the gdata-python library provided by Google, which in turn uses the Google API.


GOOGLE AUTHENTICATION collective.googleauthentication

 To let the Plone application access the documents stored on Google servers, it is necessary to complete the authentication procedure for Web applications provided by Google Docs. The procedure allows Web applications to authenticate users through their Google accounts. For security reasons, the application acquires an authentication token which will later be used to dowload or upload documents from Google servers without explicitly providing the user's credentials. The Plone user is redirected to a Google page that invites him to insert his credentials. Once he logs in with his Google account, the user is asked to authorize the Plone application to access his documents. Then, if the user grants access, he is pointed again to the Plone site. The URL of the last redirection embeds the authentication token which, as mentioned above, allows the Plone application to access the user's documents on Google servers for the following requests. GA inititates the authentication procedure upon Google Docs immediately after the user has logged into the Plone application. The procedure will be executed just once, as when the Plone application obtains the authentication token, it will store as an attribute, google_token, in the user profile.


GOOGLE SYSTEM STORAGE collective.googlesystemstorage

GSS saves the document types supported by the Google Docs service on the Google servers, while storing all the other files in the local filesystem, so that Plone users to access their files from both the Plone application and their Google Docs account. GSS extends FSS through a meta ZCML directive will trigger the adoption of GSS as storage. GSS provides several utility methods: a method that takes an authentication token and returns a client for Google Docs, methods that take care of uploading, downloading and deleting the documents on Google servers, and a method that performs queries on documents stored on Google servers.


GOOGLE SHARING collective.googlesharing

GS manages the sharing of documents stored in the Google servers and their synchronization from the Plone application to Google Docs service. In this way, when a Plone user changes the roles of other users on a specific document, GS changes the document sharing attributes in the Google Docs service accordingly. So, if a Plone user assigns another user the Editor role on one of his documents, the other user will be able to read and modify that document through his Google account. To associate Plone and Google accounts, the system assumes that the email address attribute of Plone users corresponds to their Google account. The sharing attributes of documents stored in Google servers is managed through the feed access control list (ACL), a list that shows the Google users that have access to a specific resource. GS redefines the googlesharing view to perform the mapping of roles and the ACL feed retrieval and changing operations.


GOOGLE MODIFY CONTENT collective.googlemodifycontent

GMC extends the Plone content Edit function by adding the GoogleModify operation, which only applies to documents stored on Google servers. GMC embeds the Google Docs application inside the GoogleModify panel, allowing Plone users to edit their documents directly from the Google Docs application. GMC provides the new googlemodifycontent view, that takes care of discovering the specific URL of the Google Docs document function and of embedding that page in the current window of the Plone application.

 

One idea for improving the system is using the workflow, instead of directly manipulating roles and permissions associated with content.

 

Mar 01, 2010

Integration of PloneGazette with plone.app.discussion

Filed Under:

The new product collective.discussionintegration.plonegazette provides the integration of PloneGazette and plone.app.discussion.

The product plone.app.discussion is becoming the standard way to add comments in Plone. If both products plone.app.discussion and Products.PloneGazette are installed the creation of any PloneGazette content type fails, because PloneGazette content types not provide the adapter for "IConversation":

Traceback (innermost last):
  ...
  Module plone.app.discussion.catalog, line 29, in total_comments
TypeError: ('Could not adapt', <NewsletterTheme at /ausl/newslettertheme.2010-01-26.2440135204>, <InterfaceClass plone.app.discussion.interfaces.IConversation>)

 

 

To solve the problem we set an adapter for the types defined in Products.PloneGazette. This adapter provides the interface "IConversation" of plone.app.discussion. The adapter provides the attribute "total_comments" and the method "enabled", which returns False (means that the commeting is disable).

<adapter
      for="Products.PloneGazette.interfaces.INewsletterTheme"
      factory=".newsletter.NewsletterConversation"
      provides="plone.app.discussion.interfaces.IConversation"
      />

 

So you can create objects Newsletter without any problem.

Unfortunately PloneGazette does not define an interface for each content types, so through zcml we say that these content type implements a particular interfaces.Then we give the adapter for those interfaces.


The new product collective.discussionintegration.plonegazette makes possible the creation of the PloneGazette content types if there is an installation of plone.app.discussion in your instance.

http://svn.plone.org/svn/collective/collective.discussionintegration.plonegazette/