|
Last change
on this file since 964 was
964,
checked in by crchemist, 19 years ago
|
|
Created dir for bundles.
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [956] | 1 | from random import randint |
|---|
| 2 | |
|---|
| [963] | 3 | from Products.CMFCore.utils import getToolByName |
|---|
| [956] | 4 | |
|---|
| [963] | 5 | from quintagroup.plonecaptchas.config import CAPTCHA_KEY, CONFIGLET_ID, \ |
|---|
| 6 | ALL_LAYERS, PROPERTY_SHEET |
|---|
| 7 | |
|---|
| [956] | 8 | def generateKey(length): |
|---|
| 9 | key = '' |
|---|
| 10 | for i in range(length): |
|---|
| 11 | key += str(randint(0, 9)) |
|---|
| 12 | return key |
|---|
| 13 | |
|---|
| 14 | def setupVarious(context): |
|---|
| 15 | if context.readDataFile('quintagroup.plonecaptchas_various.txt') is None: |
|---|
| 16 | return |
|---|
| 17 | |
|---|
| 18 | site = context.getSite() |
|---|
| 19 | |
|---|
| 20 | # set captcha key |
|---|
| 21 | value = generateKey(8) |
|---|
| 22 | if site.hasProperty(CAPTCHA_KEY): |
|---|
| 23 | site._updateProperty(CAPTCHA_KEY, value) |
|---|
| 24 | else: |
|---|
| 25 | site._setProperty(CAPTCHA_KEY, value, 'string') |
|---|
| [963] | 26 | |
|---|
| 27 | def uninstall(context): |
|---|
| 28 | # Only run step if a flag file is present (e.g. not an extension profile) |
|---|
| 29 | if context.readDataFile('quintagroup.plonecaptchas_uninstall.txt') is None: |
|---|
| 30 | return |
|---|
| 31 | |
|---|
| 32 | site = context.getSite() |
|---|
| 33 | |
|---|
| 34 | # remove configlet |
|---|
| 35 | cpt = getToolByName(site, 'portal_controlpanel') |
|---|
| 36 | if CONFIGLET_ID in [o.id for o in cpt.listActions()]: |
|---|
| 37 | cpt.unregisterConfiglet(CONFIGLET_ID) |
|---|
| 38 | |
|---|
| 39 | # remove property sheet |
|---|
| 40 | pp = getToolByName(site, 'portal_properties') |
|---|
| 41 | if PROPERTY_SHEET in pp.objectIds(): |
|---|
| 42 | pp.manage_delObjects(ids=[PROPERTY_SHEET]) |
|---|
Note: See
TracBrowser
for help on using the repository browser.