Upgrade to Pro — share decks privately, control downloads, hide ads and more …

v2.helsinki.at: Django und Plone im neuen Webauftritt von Radio Helsinki

v2.helsinki.at: Django und Plone im neuen Webauftritt von Radio Helsinki

Django ist ein Web-Framework in Python. Plone ist ein (Enterprise) Content-Management-System das auf dem Applikations-Server Zope basiert und ebenfalls in Python geschrieben ist. Im neuen Web-Auftritt von Radio Helsinki werden beide eingesetzt. Der Vortrag gibt eine Einführung in Django und Plone, erläutert die Stärken und Schwächen der Systeme, zeigt welche Teile der neuen Website mit welchem System realisiert wurden, wie die Integration realisiert wurde und welche Probleme dabei zu lösen waren. Der neuen Webauftritt von Radio Helsinki wird im März 2011 freigeschaltet werden.

Ernesto Rico Schmidt

April 09, 2011
Tweet

More Decks by Ernesto Rico Schmidt

Other Decks in Programming

Transcript

  1. Einführung Die bisherige Lösung http://helsinki.at, seit Jänner 2001 PHP/MySQL Kein

    Framework Kein Content Management System Erstes Web und PHP-Projekt HTML-Tabellen Zwei SQL-Tabellen 2005 Sendungen seit 2001
  2. Einführung Die Anforderungen Neues Design Content Management System Neue Programmverwaltung

    Direkte Verlinkung mit der CBA (Cultural Broadcasting Archiv, http://cba.fro.at) Einfache Möglichkeit Kommentare zu Sendungen abzugeben
  3. Einführung Django http://www.djangoproject.com ursprünglich von Adrian Holovaty, Simon Wilson, Jacob

    Kaplan-Moss und Wilson Miner für World-Online in 2003 enwicklet. offen (BSD-Lizenz) seit 2005 Version 1.0 in September 2008 Version 1.1 in Juli 2009 Version 1.2 in Mai 2010 Version 1.3 in März 2011 Prominentes Beispiel: http://disqus.com/ “Serving 400 million people with Python”
  4. Einführung Plone CMS System Programmiersprache: Python Applicationserver: Zope (Zope Object

    Publishing Environment) Datenbank: ZODB (Objektorientiert) Benutzerfreundlich (User), Umfangreich (Admins), Flexibel (Developer)
  5. Die Programmverwaltung BroadcastFormat id AutoField format CharField slug SlugField ShowInformation

    id AutoField information CharField abbrev CharField slug SlugField ShowTopic id AutoField topic CharField abbrev CharField slug SlugField MusicFocus id AutoField focus CharField abbrev CharField slug SlugField Host id AutoField name CharField email EmailField website URLField Show id AutoField predecessor ForeignKey broadcastformat ForeignKey name CharField slug CharField image ImageField short_description CharField description TextField email EmailField website URLField cba_series_id IntegerField created DateTimeField last_updated DateTimeField hosts ManyToManyField owners ManyToManyField showinformation ManyToManyField showtopic ManyToManyField musicfocus ManyToManyField broadcastformat showinformation showtopic musicfocus hosts predecessor User owners RRule id AutoField name CharField freq IntegerField interval IntegerField bysetpos IntegerField count IntegerField ProgramSlot id AutoField rrule ForeignKey byweekday IntegerField show ForeignKey dstart DateField tstart TimeField tend TimeField until DateField is_repetition BooleanField created DateTimeField last_updated DateTimeField show rrule TimeSlot id AutoField programslot ForeignKey start DateTimeField end DateTimeField show ForeignKey show programslot Note id AutoField timeslot OneToOneField owner ForeignKey title CharField content TextField status IntegerField cba_entry_id IntegerField start DateTimeField show ForeignKey created DateTimeField last_updated DateTimeField show timeslot owner
  6. Die Programmverwaltung Manager # program/models.py class TimeSlotManager(models.Manager): def get_or_create_current(self): try:

    return TimeSlot.objects.get( start__lte=datetime.now(), end__gt=datetime.now()) except ObjectDoesNotExist: once = RRule.objects.get(pk=1) today = date.today().weekday() default = Show.objects.get(pk=1) previous = TimeSlot.objects.filter( end__lte=datetime.now()).order_by(’-start’)[0] next = TimeSlot.objects.filter( start__gte=datetime.now())[0]
  7. # program/models.py dstart = previous.end.date() tstart = revious.end.time() until =

    next.start.date() tend next.start.time() new_programslot = ProgramSlot( rrule=once, byweekday=today, show=default, dstart=dstart, tstart=tstart, tend=tend, until=until) new_programslot.save() return new_programslot.timeslots.all()[0]
  8. Die Programmverwaltung Administration # program/admin.py class NoteAdmin(admin.ModelAdmin): def queryset(self, request):

    qs = super(NoteAdmin, self).queryset(request) if request.user.is_superuser: return qs else: return qs.filter(owner=request.user) def save_model(self, request, obj, form, change): obj.owner = request.user obj.save()
  9. Die Programmverwaltung Administration # program/admin.py def formfield_for_foreignkey( self, db_field, request,

    **kwargs): if db_field.name == ’timeslot’: if request.user.is_superuser: kwargs[’queryset’] = \ TimeSlot.objects.filter(start__gt=datetime.now) else: shows = request.user.shows.all() kwargs[’queryset’] = \ TimeSlot.objects.filter( show__in=shows, start__gt=datetime.now) return \ super(NoteAdmin, self).formfield_for_foreignkey( db_field, request, **kwargs)
  10. Die Solr-Integration # settings.py INSTALLED_APPS = ( .. ’haystack’, ..

    ) HAYSTACK_SITECONF = ’helsinki.search_sites’ HAYSTACK_SEARCH_ENGINE = ’solr’ HAYSTACK_SOLR_URL = ’http://localhost:8983/solr’
  11. Die Solr-Integration # program/search_indexes.py from haystack.indexes import CharField, DateTimeField, \

    SearchIndex from haystack import site from datetime import datetime from program.models import Show class ShowIndex(SearchIndex): text = CharField(document=True, use_template=True) last_updated = DateTimeField(model_attr=’last_updated’) def get_queryset(self): return Show.objects.filter( last_updated__lte=datetime.now()) site.register(Show, ShowIndex)
  12. Die Solr-Integration {# templates/search/indexes/program/show_text.txt #} {{ object.name }} {{ object.description

    }} {{ object.short_description }} $ ./manage.py build_solr_schema > schema.xml $ ./manage.py rebuild_index
  13. Die LDAP-Integration # settings.py import ldap from django_auth_ldap.config import LDAPSearch,

    \ PosixGroupType AUTH_LDAP_SERVER_URI = "ldap://ldap.helsinki.at" AUTH_LDAP_BIND_DN = "cn=reader,dc=helsinki,dc=at" AUTH_LDAP_BIND_PASSWORD = ".." AUTH_LDAP_USER_DN_TEMPLATE = \ "uid=%(user)s,ou=people,dc=helsinki,dc=at" AUTH_LDAP_GROUP_SEARCH = LDAPSearch( "ou=groups,dc=helsinki,dc=at", ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)" ) AUTH_LDAP_GROUP_TYPE = PosixGroupType()
  14. Die LDAP-Integration # settings.py AUTHENTICATION_BACKENDS = ( ’django_auth_ldap.backend.LDAPBackend’, ) AUTH_LDAP_USER_ATTR_MAP

    = { "first_name": "givenName", "last_name": "sn", "email": "mail" } AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_staff": "cn=pvstaff,ou=groups,dc=helsinki,dc=at", "is_superuser": "cn=Technik,ou=groups,dc=helsinki,dc=at" } AUTH_LDAP_ALWAYS_UPDATE_USER = True AUTH_LDAP_FIND_GROUP_PERMS = True AUTH_LDAP_MIRROR_GROUPS = True
  15. Plone is among the top 2% of all open source

    projects worldwide, with 340 core developers and more than 300 solution providers in 57 countries. The project has been actively developed since 2001, is available in more than 40 languages, and has the best security track record of any major CMS. It is owned by the Plone Foundation, a 501(c)(3) not-for-profit organization, and is available for all major operating systems. Sources: CVE and Ohloh. Quelle: plone.org
  16. EXO 2010 Content Technology Vendor Map (Continues 50km to University)

    To: Collaboratown – COVEO NORTH PLAINS LASERFICHE – CA – FABASOFT – DOCUWARE – OBJECTIVE ALFRESCO XEROX DAY NUXEO IBM OPEN TEXT/ VIGNETTE ORACLE/SUN MICROSOFT SAPERION AUTONOMY/ INTERWOVEN NEWGEN EVER SPRINGCM HYLAND ADOBE HP KIT DIGITAL MEDIABEACON WAVE – ENDECA – VIVISIMO – ISYS SINEQUA EXALEAD DTSEARCH – DIESELPOINT – METALOGIX – BAMBOO SOLUTIONS – QUEST KNOWLEDGELAKE – – AVEPOINT OMNIRIM – – BLUESPRING – K2 NINTEX – BA–INSIGHT – NEWSGATOR – CORASWORKS – – THUNDERSTONE – LUCENE RECOMMIND SAP – UPORTAL BROADVISION – – JACKBE – WSO2 – KAPOW – JETSPEED – REDHAT – LIFERAY – ADAM – CANTO – WIDEN – FEDORA EMC GOOGLE PLONE DRUPAL SOCIALTEXT MEDIAWIKI TRACTION – KICKAPPS SALESFORCE – ATLASSIAN MOVEABLE TYPE – WORDPRESS FATWIRE – LITHIUM – PLUCK TYPO3 – MAGNOLIA – – HIPPO – COREMEDIA – ALTERIAN – EKTRON SITECORE KENTICO E-SPIRIT VYRE TERMINALFOUR – TELERIK HANNON HILL – OPENCMS – CROWNPEAK – CLICKABILITY – OMNIUPDATE – EPISERVER – PAPERTHIN – EZ PUBLISH – DOTNETNUKE – JOOMLA – – YAMMER – CISCO AT INTERNET – – JIVE – BLUEKIWI – AWARENESS – MINDTOUCH – TELLIGENT LYRIS INTELLITRACKER WEBTRENDS YAHOO! COREMETRICS UNICA NEDSTAT SDL TRIDION SIBERLOGIC TRISOFT MARK LOGIC – VASONT AUTHORIT QUARK – – PTC JUSTSYSTEMS – EMPOLIS To: Nichy To: XMLand To: Video Drive – PERCUSSION – – – – – – – – – – – – – GLOBAL360 – – – IDEVFACTORY – EQUILIBRIUM – – – – – – – – Real Story Group’s vendor evaluations and advisory services have helped thousands of organizations find their way. We can help you too. Take a test ride—download a sample today: www.realstorygroup.com/try © 2010 Real Story Group www.realstorygroup.com/vendormap/ KEY Enterprise Content Management Web Content Management Portals & Content Integration Web Analytics Search & Information Access Multichannel Publishing Collaboration & Social Software Digital Asset Management SharePoint Add-ons
  17. CMS Vergleich None Fair Solid Excellent Ease of Hosting and

    Installation Ease of Setup: Simple Site Ease of Setup: Complex Site Ease of Use: Content Editors Ease of Use: Site Administrator Graphical Flexibility Accessibility and Search Engine Optimization Structural Flexiblity User Roles and Workflow Community/Web 2.0 Functionality Extending and Integrating Security Support/Community Strength WordPress J oomla Drupal Plone Source: idealware - December 2010 - Comparing Open Source Content Management Systems 1.5.21 1.6 6.19 7.0
  18. Deliverance - History Zope Site Themes XDV / Diazo DVNG

    Deliverance 0.4 XSLT Renderer Python Renderer Deliverance 0.2 2005, Paul Everitt 2007 2008 2008 - 2011