##################################################
# SPYCE - Python-based HTML Scripting
# Copyright (c) 2002 Rimon Barr.
#
# Refer to spyce.py
# CVS: $Id: core.py 1172 2006-08-29 16:59:46Z ellisj $
##################################################
__doc__ = '''Core Spyce tags.'''
import os.path
from spyceTag import spyceTagLibrary, spyceTagPlus, spyceTag, invokeSingleton
from spyceException import spyceDone
import spyce, spyceUtil
from _formhelper import formatArgs
_parent_files = {}
class tag_parent(spyceTagPlus):
name = 'parent'
def syntax(self):
self.syntaxSingleOnly()
def filename(self, uri):
return spyceUtil.url2file(uri, self.getModule('request').filename())
def find_parent(self, src):
if not src:
# check for parent file in current directory
# (we don't climb further up the path tree, though; that doesn't make
# sense for CGI-based installations)
immediateparent = self.filename('parent.spi')
if os.path.exists(immediateparent) \
and immediateparent != self.getModule('request').filename():
src = 'parent.spi'
else:
src = spyce.getServer().config.defaultparent
if not src:
raise 'src not specified, no parent.spi found in current directory, and defaultparent not configured'
return src
def begin(self, src=None, **kwargs):
key = (self.getModule('request').filename(), src)
try:
pfile = _parent_files[key]
except KeyError:
pfile = _parent_files[key] = self.filename(self.find_parent(src))
if self._api._parent:
spyce.DEBUG('warning: replacing old parent %s with %s' % (self._api._parent, src))
self._api._parent = (pfile, kwargs)
# most of the work here is special-cased by spyceCompile
class tag_login_required(spyceTagPlus):
name = 'login_required'
def syntax(self):
self.syntaxSingleOnly()
def begin(self, validator=None):
import spyceConfig
invokeSingleton(self._api, spyceConfig.loginrequired_render)
raise spyceDone()
# most of the work here is special-cased by spyceCompile
class tag_login(spyceTagPlus):
name = 'login'
def syntax(self):
self.syntaxSingleOnly()
def begin(self, validator=None):
self.parentRequired('form')
import spyceConfig
invokeSingleton(self._api, spyceConfig.login_render)
# modified from code generated by spyceCompile from the following:
# [[.begin name=logout singleton=True]]
#
| %s | ' % item) self.getOut().write('