# -*- coding: utf-8 # -*- Mode: Python; py-indent-offset: 4 -*- # $Id: __init__.py 33 2006-06-02 06:49:13Z vahur $ # # Copyright (c) 2007, Vahur Rebas # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ Space is a container for different RSS pages that user can create """ import Globals from Globals import Acquisition, Persistent from Acquisition import aq_base, aq_inner, aq_parent, Explicit from AccessControl import ClassSecurityInfo from OFS.Folder import Folder class Space(Folder, Persistent, Explicit): """ Space """ meta_type = "Space" security = ClassSecurityInfo() security.declareObjectPublic() manage_options = Folder.manage_options def __init__(self, id, access_token): self.id = id self._access_token = access_token security.declarePrivate('manage_afterAdd') def manage_afterAdd(self, item, container): pass def index_html(self, REQUEST): """ index html """ return "Hi! It's a space" def _getAccessToken(self): return self._access_token def _getPages(self): return self.objectValues('Page') def _newPage(self, title, pipeline): from utils import gen_key from Page import Page view_token = gen_key('view_token') edit_token = gen_key('edit_token') p = Page(gen_key('page'), view_token, edit_token, title) self._setObject(p.id, p) obj = getattr(self, p.id) piperes = obj._setPipeline(pipeline) res = {} res['view'] = view_token res['edit'] = edit_token res['url'] = obj.absolute_url() res['title'] = title #return {'view': view_token, 'edit': edit_token, 'url':obj.absolute_url(), 'title':title } return piperes, res def _getPage(self, view_token='', edit_token='', json = 1): for p in self._getPages(): if p._getEditToken() == edit_token: return p return None def _deletePage(self, edit_token): p = self._getPage(edit_token = edit_token, json = 0) if not p: return {'errno':4, 'errstr':'Page not found'} self._delObject(p.id) return {'errno':0} Globals.InitializeClass(Space)