Scripts posted recently tagged to zope in Kelpi

1- 10 of 27.

discover if devmode is enabled in zope.conf

to python zope devmode config by nando.quintana

from zope.app.appsetup.appsetup import getConfigContext
def is_devmode_enabled():
    """Is devmode enabled in zope.conf?"""
    config_context = getConfigContext()
    return config_context.hasFeature('devmode')

Use a custom lexicon and splitter with Zope3 Catalog

to zope zope3 custom splitter lexicon python by anonymous

from zope.app.catalog.catalog import Catalog
from zope.app.catalog.text import TextIndex
from zope.index.text.interfaces import ISearchableText
from zope.index.text.lexicon import Lexicon, CaseNormalizer, StopWordRemover
import re

Set the selected attribute on a select box

to zope plone tal xml by nando.quintana

<option value="this_value" tal:attributes="selected python:test(my_value=='this_value','selected',)">this value</option>

cronjob for backuping a Data.fs

to cron zope backup repozo buildout by mikel

To backup a Data.fs in a buildout-based environment, just add this line to your crontab
@daily /var/zope/myinstance/bin/repozo -BzQ -f /var/zope/myinstance/var/filestorage/Data.fs -r /var/backups

Do you have this app in your facebook profile?

to facebook zope zpt by nando.quintana

<html>
  <head>
    <title>Has App?</title>
  </head>
  <body>

Return in json and jsonp (json with callback) from zope

to zope json jsonp python by nando.quintana

results  = u"{"
results += u"%s:%s," % (u"'title'",u"'"+title+u"'")
results += u"%s:%s," % (u"'body'",u"'"+body+u"'")
results += u"%s:%s," % (u"'ptitle'",u"'<a target=\"_top\" href=\"http://apps.facebook.com/tagzania/point/"+point_id+u"\">"+ptitle+u"</a>'")
results += u"%s:%s," % (u"'plat'",u"'"+plat+u"'")

Copying a FileStorage to PGStorage

to python zope filestorage pgstorage postresql by mikel

(having all zope directories in you PYTHONPATH, open a PYTHON prompt)
>>> from ZODB.FileStorage import FileStorage
>>> from PGStorage.pgstorage import PGStorage
>>> src = FileStorage('/path/to/your/Data.fs', read_only=1)
>>> pg = PGStorage(name='PGStorage', params='host=localhost port=5432 dbname=DBNAME user=DBUSER password=DBPASS')

A profiler for Zope 2 (II)

to profiler zope dtml by nando.quintana

<dtml-let time0="profiler()">
----------------------<dtml-var "time0[1]">----------------------init<br/>
<dtml-let time1="profiler(time0[0])">
----------------------<dtml-var "time1[1]">----------------------point 1<br/>
</dtml-let> <!-- time1 profiler -->

A profiler for Zope 2

to profiler dtml zope python by nando.quintana

now = DateTime()
if datetime == '':
  lap = 0
else:
  lap = 100000 * (now - DateTime(str(datetime)))

Binnary random (True/False)

to binnary random zope python by nando.quintana

return (int(str(DateTime()).split('.')[1].split(' ')[0]) > 500)
hits counter