Re: [Zope] Re: Preserving Context

2006-12-13 Thread Maciej Wisniowski

 Yes there is a 'return 0' at the beginning.
 This code always executes and works just fine,
 as I've mentioned before, as long as the template is in the root
 folder of the given Web site. I'm trying to put this template in a
 root folder that services all the Web sites of the portal, and
 that's where I'm having trouble.
So this is not because of this code. Your script
ALWAYS returns '0' and does nothing more.
Just try to remove everything after 'return 0' and see
if it changes anything or remove 'return 0' and see
what happens then.

-- 
Maciej Wisniowski
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: Preserving Context

2006-12-13 Thread Javier Subervi
- Original Message 
From: Maciej Wisniowski [EMAIL PROTECTED]


So this is not because of this code. Your script
ALWAYS returns '0' and does nothing more.
Just try to remove everything after 'return 0' and see
if it changes anything or remove 'return 0' and see
what happens then.

Crap. You're right. Back to square one...
Javier


 

Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.com___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: Preserving Context

2006-12-12 Thread Jonathan
In your root folder you could have a script that accesses the ZCatalog which 
can be called from any subfolder and can tell where it was called from... try 
the following:  create a python script (tst) in your root folder that contains 
the following code:

return str(traverse_subpath)


then invoke this script file as followings:

http:/your.web.site/tst
http:/your.web.site/tst/folderA
http:/your.web.site/tst/folderB/folderC

(substitute your own subfolders as required)

This may get you what you are looking for.

Alternatively, if you need more control over the parameters that are getting 
sent to the script file in the root folder, then you could create a script file 
in each subfolder which calls the 'root script' with the necessary 'localized' 
parameters.


Jonathan


  - Original Message - 
  From: Javier Subervi 
  To: zope@zope.org 
  Sent: Tuesday, December 12, 2006 11:55 AM
  Subject: [Zope] Re: Preserving Context


  From: Jonathan [EMAIL PROTECTED]
  
  From: Suresh V [EMAIL PROTECTED]

  In your script you could access the catalog as follows:
   
  afolder = context.restrictedTraverse('folderA/folderB/'+someLocalFolder) 
   # pass 'someLocalFolder' as a parameter
  catalog = afolder.Catalog# assuming you have named your ZCatalog 
'Catalog'

  The problem with this, is that this script is used at the base of a portal 
with several different Web sites, therefore, the root folder of each is 
different.

  And where is mycontext defined? You will need a tal:define=mycontext here 
or something.

  I added the following:

  div align=center 
 tal:define=mycontext here
 tal:condition=here/hasSearchEngine(mycontext)

  ...but that didn't seem to help any:

  Error Type: KeyError
  Error Value: 'hasSearchEngine(mycontext)'

  Concerning your comment about the except, this script was written by an 
employee of mine. I'm now picking up where he left off. I cleaned it up ;)
  TIA,
  Javier



--
  Want to start your own business? Learn how on Yahoo! Small Business.


--


  ___
  Zope maillist  -  Zope@zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists - 
   http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: Preserving Context

2006-12-12 Thread Jonathan
The script routine doesn't have to be located in root.  traverse_subpath is 
populated using the names of all subfolders that occur after the script file 
name in the URL.  So if your URL is:  
http:/my.web.site/folderA/scriptA/folderB/folderC, then scriptA will receive a 
traverse_subpath variable (in REQUEST namespace) that contains ['folderB', 
'folderC'].  Note: this will not work if there are any other scripts, DMTL 
methods etc in the URL after 'scriptA'.



Jonathan
  - Original Message - 
  From: Javier Subervi 
  To: zope@zope.org 
  Sent: Tuesday, December 12, 2006 1:48 PM
  Subject: [Zope] Re: Preserving Context


  From: Jonathan [EMAIL PROTECTED]
   
  What version of zope are you running? (I am running zope 2.9.2 on a linux 
box).
  2.7.8

  I didn't put it in 'root' since root isn't automatically called. I put it in 
a folder called 's' which is automatically called, then I also explicitly 
called it in the URL. Obviously, if the fn weren't found, Zope would have 
complained. It was in fact found.
  TIA,
  Javier



--
  Any questions? Get answers on any topic at Yahoo! Answers. Try it now.


--


  ___
  Zope maillist  -  Zope@zope.org
  http://mail.zope.org/mailman/listinfo/zope
  **   No cross posts or HTML encoding!  **
  (Related lists - 
   http://mail.zope.org/mailman/listinfo/zope-announce
   http://mail.zope.org/mailman/listinfo/zope-dev )
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: Preserving Context

2006-12-12 Thread Maciej Wisniowski
As far as I understand you have script (say it has id 'handle_404_scr')
that handles 404 errors in 'root' folder. In this script you have
something like:
div align=center
   tal:define=mycontext here
   tal:condition=here/hasSearchEngine(mycontext)

Yes? So how is this script called?


I'm not sure what exactly is your case but you may try:

div align=center
   tal:condition=here/hasSearchEngine(here/aq_inner)

or just (without passing a parameter):

div align=center
   tal:condition=here/aq_inner/hasSearchEngine()



-- 
Maciej Wisniowski
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: Preserving Context

2006-12-12 Thread Jonathan

- Original Message - 
From: Javier Subervi 
To: zope@zope.org 
Sent: Tuesday, December 12, 2006 2:29 PM
Subject: [Zope] Re: Preserving Context


The script routine doesn't have to be located in root.  traverse_subpath is 
populated using the names of all subfolders that occur after the script file 
name in 
the URL.  So if your URL is:  
http:/my.web.site/folderA/scriptA/folderB/folderC, 
then scriptA will receive a traverse_subpath variable (in REQUEST namespace) 
that contains ['folderB', 'folderC'].  Note: this will not work if there are 
any other scripts, DMTL methods etc in the URL after 'scriptA'.

I figured out what I was doing wrong. Apparently, the script needs to be 
called *before* the folders. I had put it at the end. Okay, that works, so 
now how do I incorporate it? I'm running into trouble here. I've rewritten the 
following line several times, and several times gotten it wrong. Perhaps you 
could steer me right?

div align=center 
   tal:define=mycontext python:`here.traverse_subpath`
   tal:condition=here/hasSearchEngine(mycontext)



Your page template just needs to construct a URL (that your users can access - 
eg. in an html link) that contains the name of the script file at the beginning 
of the URL (ie. before the target subfolder(s)).

The script file will have to use the traverse_subpath contents to build a 
string which you can then use to access the required folder:

targetFolder = string.join(traverse_subpath, '/')#you will have to play 
with this to get the right target folder for your app
aFolder = context.restrictedTraverse(targetFolder)
searchRes = aFolder.Catalog(some search string here)
do something with search results here



Jonathan


Any questions? Get answers on any topic at Yahoo! Answers. Try it now.



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )