Re: Programmatic parents?
Philip Semanchuk <[email protected]>
| Newsgroups | gmane.comp.python.spyce.general |
|---|---|
| Message-ID | <[email protected]> |
On Aug 6, 2006, at 12:47 PM, Iwan Vosloo wrote:
> this may be a strange question... I use the programmatic interface
> (spyce.spyceFileHandler) to render documents. I'd like to render a
> parent document "around" the documents I render in this way _without_
> having to specify a <spy:parent...> tag in the templates.
>
> How can I do this? Would I have to first render the child, then render
> the parent template, passing it.. the child somehow?
Hi Iwan,
Something like this should work. (I cobbled this example together
w/copy & paste; please excuse any errors):
import spyceCmd
import spyce
import spycePreload
def ExecuteSpyce(SpyceConfigModule, ScriptName, parameters,
OutputFileName):
sig = ','.join(parameters.keys())
f = file(OutputFileName, "w")
request = spyceCmd.spyceCmdlineRequest(sys.stdin, os.environ,
ScriptName)
response = spyceCmd.spyceCmdlineResponse(f, sys.stderr, False)
# The magic incantation to invoke the spyceFileHandler comes from
here:
# http://sourceforge.net/mailarchive/message.php?msg_id=13964368
spyce.spyceFileHandler(request, response, ScriptName, sig=sig,
kwargs=parameters, config=SpyceConfigModule)
response.close()
f.close()
SpyceConfigModule =
spycePreload.getConfigModule(spycePreload.defaultConfigFile())
ExecuteSpyce(SpyceConfigModule, "child.spy", { }, "child.html")
params = { "FilenameToInclude" : "child.html" }
ExecuteSpyce(SpyceConfigModule, "parent.spy", params, "parent.html")
HTH
Philip
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV