Create a membrane based content item (it just needs to implement certain interfaces defined in membrane.interfaces)Register the type with membranetoolImportant: Set the active workflow status (the state in which a member can login)
[...]
In order for anonymous users to be able to add a content item inside a folder, the following permissions need to be had:
In the parent folder:
ViewAdd portal contentAccess content informationCreate XXX (for example, if the content item has a "creation_permission", this permission needs to be had.
On the object:
ViewModify portal contentAccess content information [...]
Archetypes validators are used in the schema definition for a field. Default validators include isEmail, isURL, etc. This is how to create a new validator:
First, the validator has to be registered with Archetypes, or zope will complain at startup and ignore the validator. So add something like this in the __init__.py of the product:
from Products.validation import validation
from validators import SamePasswordValidator
validation.register(SamePasswordValidator('isSamePassword'))Next, the source code for the validator (validators. [...]
An observation: when you want to specify the roles that are required for a user to have in order to create a piece of content, you'll have to also specify a creation permission.
This means that the following tagged values are required, to something like:
creation_permission = Create MyContent
creation_roles = python: ('Anonymous', 'Member')This generates the following code in config.py:
DEFAULT_ADD_CONTENT_PERMISSION = "Add portal content"
setDefaultRoles(DEFAULT_ADD_CONTENT_PERMISSION, ('Manager', 'Owner'))
ADD_CONTENT_PERMISSIONS = { [...]
The final step is to "compile" everything into Windows executables using py2exe. For this I have the following setup.py file:
from distutils.core import setup
import py2exe
import sys
# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.version = "0.1.0"
self.company_name = "Pixelblaster Romania"
self.copyright = "Copyright 2006 Pixelblaster Romania"
self.name = " [...]
This third part shows the code needed to start/stop and set the startup type for the service. Actually, most of the necessary code sits in a ActiveState python-cookbook recipe, found here.
So, the code, using the recipe is simple (well, except that it's presented as a wxwidgets windows):
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.4.1cvs on Mon Aug 21 19:12:22 2006
import wx
from dlgControlerMainFrame import dlgControlerMainFrame [...]
This part of the recipe shows the python code needed to create (install) the Windows service. I didn't write most of this, I just found it somewhere on the internet. Credit due to the original author.
import sys
import win32service, win32serviceutil
from config import SERVICE_NAME, SERVICE_DISPLAY_NAME, SOFTWAREPATH
service_path = "%s\myservice.exe" % SOFTWAREPATH
def debug(msg):
print msg
def removeSvc():
debug('called removeSvc()')
win32serviceutil.RemoveService(SERVICE_NAME)
debug('...service was removed')
def installSvc():
debug('installSvc()')
hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS) [...]
I'm starting a longer piece on creating and managing a python based Windows service, so look for the other parts in this blog for the complete "recipe"
First, our tools: py2exe has, among its deployment targets, a "windows service" option, so we'll need that. To manage the service and interact with the Windows event log, the Python win32 extension is needed. Py2exe has a sample service in the samples/advanced folder, on which I've based my code. [...]
Sometimes you have code that has a lot of print statements, which are helping you with debugging. But what happens if you try to port that code to an environment without a console? In the best case, you won't see the prints anymore, in the worse case, the code will fail because there's no "valid file descriptor" to which to write.
The solution to this problem is to replace python's stdout file, which will enable the code output to be recorded and maybe logged for debugging purposes. [...]
I'm replacing a tinydns server with bind9, so I may as well put the setup here, as future reference.
First,
yum install bind-chroot
to install the chrooted bind server.
Next, edit the /var/named/chroot/etc/named.conf
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
recursion no;
};
//root global
//life
zone "life.org.ro" {
type master;
file "/etc/db.life.org.ro";
notify yes;
};
zone "0.0.127.in-addr.arpa" {
type master;
file "/etc/db.localhost";
allow-update { none; };
};
zone " [...]