On 30.11.2012 13:44, Samuele Kaplun wrote:

Hi!

Meanwhile, since you posted your nice example of code, may I give some advices
of best practices that might not be obvious, and could be useful to other
developers wishing to extend Invenio?

Always welcome, of course.

def index(req, f=None, doi=None, c=CFG_SITE_NAME, ln=CFG_SITE_LANG):
      """
      This interface should get parameters by URL and return names
      """
      uid     = getUid(req)
      docroot = req.subprocess_env['DOCUMENT_ROOT']

      # TODO these configs shouldn't live here!
      perl        = '/usr/bin/perl'
      scriptpath  = docroot+'/cgi-bin/'

Note that the docroot is always available in invenio.config.CFG_WEBDIR,

Ok. I wasn't aware of that.

      if uid > 0:

Beware that uid > 0 is not a guarantee that your user is authenticated. That
depends on the variable CFG_WEBSESSION_DIFFERENTIATE_BETWEEN_GUESTS. The best
way to check if a user is a guest is to use invenio.webuser.isGuestUser(uid)
or to use the swiss-army-knife invenio.webuser.collect_user_info(req), which
will return a dictionary with all sorts of information about the user,
including a key "guest" which will say "1" if the user is guest or "0"
otherwise (as a string).

Ok, I'll correct that as well. :)

--

Kind regards,

Alexander Wagner
Subject Specialist
Central Library
52425 Juelich

mail : [email protected]
phone: +49 2461 61-1586
Fax  : +49 2461 61-6103
www.fz-juelich.de/zb/DE/zb-fi


------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

Reply via email to