[Zope] [FAQTS] Zope Knowledge Base Update -- July 24th, 2000

Fiona Czuczman Fiona Czuczman <fiona@sitegnome.com>
24 Jul 2000 07:27:08 -0000


Hi Guys,

Here are the latest entries to be entered into http://zope.faqts.com

I'm sending this out now so list subscribers get an idea how the 
summaries work, if they haven't seen the python summaries I mentioned in 
the thread

"[Zope] FAQ Wiki and What happend @ O'Reilly Conference" from earlier 
today.

regards,

Fiona Czuczman


## New Entries #################################################


-------------------------------------------------------------
installing Zope 2.2.0b4 via CVS
http://www.faqts.com/knowledge-base/view.phtml/aid/4845
-------------------------------------------------------------
Fiona Czuczman
T.J. Mannos

I'd just like to announce that I've installed Zope 2.2.0b4 via CVS and 
done a complete run-through of my site.  It seems to work flawlessly 
now, and I've gone ahead and installed it on my main port for a trial 
period.  I hope to launch the site using the final version of 2.2.0 (so 
hurry up, developers!!)  :)

Anyway, upgrading wasn't without its problems, so let me share with you 
some tips that will help those in my situation upgrade more 
successfully.  Note that I've skipped some steps, with the assumption 
that since your upgrading an existing Zope version, you already know how 
to install Zope.

Directories cited:
    Original installation:
        /usr/Zope-2.1.6
    Fresh install of 2.1.6 (for diff'ing changes I made in the python
modules):
        /temp/Zope-2.1.6
    New CVS install of Zope-2.2.0b4:
        /usr/local/Zope2 (I moved it to the /usr/local volume because I 
had more space there).

Products installed:
    SQLSession
    SiteAccess
    TinyTable
    ZMySQLDA
    (your product list may vary)

FIRST, I like to hack the source a lot.  I have my own special comment 
tags, such as <!--#c ... --> instead of <dtml-comment> ... 
</dtml-comment>, and I have my own special <dtml-var> modifier, 
js_friendly, which quotes all special characters so I can use them in 
JavaScript code.  On a tip from Shane, I started using CVS to download 
the Zope source code so that it would merge the changes made in each 
upgrades with the changes I've made to the source.  (Do a search for 
"CVS" on Zope.org).  However, this was my first CVS, so I still needed 
to bring over the changes I'd previously made. So.......

    cd /usr/local/Zope2
    diff -rc /temp/Zope-2.1.6/lib/python /usr/Zope-2.1.6/lib/python
>MyChanges.diff
    patch -p3 <MyChanges.diff

    NOTE: Results may vary.

By the way, in case you don't want to mess around with CVS (or you're 
like me and can't figure out how it works), the above commands should 
achieve the same effect, although you might get a few failed hunks and 
have to fix them manually.  If you don't modify the Zope source, you can 
skip this step.

SECOND, I had all my data, external methods, and installed products on 
my old installation.  I didn't want to lose them.  Now, don't be tempted 
to just copy all your Products over from the lib/python/Products folder. 
Some of them, such as SiteAccess and SQLSession, if you have them, WON'T 
WORK. (Furthermore, they'll break your installation, and you won't even 
be able to get to a management screen).  Here's what you do:

    1. Back up your new var directory (in case something goes terribly 
wrong) and copy the old data over.
        cd /usr/local/Zope2
        mv var var.bak
        cp -R /usr/Zope-2.1.6/var .

    2. Copy your external methods over.
        cp -R /usr/Zope-2.1.6/Extensions

    3. Copy *some* (not all) of your Products over.
        cd lib/python/Products
        cp -R /usr/Zope-2.1.6/lib/python/Products/TinyTable .
        cp -R /usr/Zope-2.1.6/lib/python/Products/ZMySQLDA .

    4. Start Zope (you may have to modify the startup script and the
superuser password) and load the management interface.  Delete all your
SiteRoots and SQLSessions.  You'll have to re-create them.

    5. If you're like me, you created all your 2.1.6 objects using the
superuser account.  You can't do that in 2.2.0.  So, go to your 
acl_users folder and create a new account having Manager and Owner 
privileges.

    6. Download and install new versions of SQLSession, SiteAccess, and
possibly ZMySQLDA, if you have it.
        (Be warned, though, you may have to re-create all of your 
database connections and SQL methods!)

    7. Re-start Zope and log in as the new account you just created.  
Take ownership of your root directory.  (Click "Ownership" tab, then 
"Take Ownership").

    8. Re-create your SQLSessions and SiteRoots.  Check your database 
folder to make sure your SQL sessions are all intact.  (If not, you have 
no sympathy from me.  I had to re-create all 40 of mine when I tried 
beta 2).

    9. Check for bugs -- I'm sure you'll find plenty!  If you're getting 
a lot of Unauthorized errors using external methods, check all your 
external methods and make sure each class has the property
"__allow_access_to_unprotected_subobjects__" set equal to "1".  For
instance, I had a bunch of simple objects created this way:

            class simpleClass:
                 pass

        Under 2.2, I had to do it this way:

            class simpleClass:
                __allow_access_to_unprotected_subobjects__=1
                 pass

THIRD, I'm waiting for the next release of Zope so that I can test out 
this CVS feature.  I'm excited!  Upgrading is such a pain, and I'm 
hoping CVS can help to automate that somewhat.  I'll let you know how it 
goes.  One very wise thing to do before every CVS checkout, though, is a 
complete backup of the Zope directory!  After four failed upgrades 
(including the alpha), I don't want to take my chances.


-------------------------------------------------------------
Example: To create a new object you must supply an addForm and a method to add the product.
http://www.faqts.com/knowledge-base/view.phtml/aid/4846
-------------------------------------------------------------
Fiona Czuczman
Andy Dawkins

To create a new object you must supply an addForm and a method to add 
the product.
e.g.

manage_addMyProductForm = HTMLFile('MyProductAdd',globals())

def manage_addMyProduct(self, id, title='')
        """Adds the product"""
        self.setObject(id, MyProduct(id,title))
        if REQUEST is not None:
                return self.manage_main(self, REQUEST)

The product tabs are defined in the manage_options section of the 
product.py The order is important the first item in the list is called 
when you access the object from the management screens.  The index_html 
is the default when accessed without the management screens.

For example:
    manage_options = ( # the management options available
        {'label': 'Contents',   'action': 'manage_main'},
        {'label': 'View',       'action': ''}, # defaults to index_html
        {'label': 'Properties',       'action': 
'manage_propertiesForm'},
        {'label': 'Security',   'action': 'manage_access'},
        )

Download the boring product from zope.org
It is a plain shell of an object that does nothing, but works.


-------------------------------------------------------------
How can I deactivate HTML tags?
http://www.faqts.com/knowledge-base/view.phtml/aid/4843
-------------------------------------------------------------
Fiona Czuczman
Curtis Maloney

<From the Zope Quick Reference>

html_quote
        Convert characters that have special meaning in HTML to HTML 
character entities.


-------------------------------------------------------------
When Saving changes from a version are the notes entered in the text box logged anywhere?
http://www.faqts.com/knowledge-base/view.phtml/aid/4844
-------------------------------------------------------------
Fiona Czuczman
Shane Hathaway

Problem:

When Saving changes from a version are the notes entered in the text box 
logged anywhere?  It would be handy to use them for a regular CHANGES 
file.

Solution:

They appear in the Undo log.


-------------------------------------------------------------
Using Zope, can I obtain the current exchange rates for the yen, mark, etc. at least once a day, preferrably every other 15 minutes?
http://www.faqts.com/knowledge-base/view.phtml/aid/4842
-------------------------------------------------------------
Fiona Czuczman
ethan mindlace fremen, Loren Stafford, Peter Be

It depends on where the exchange rates are.  

If you get them from a database, you can make zope display the current
rates. 

If you get them from a web page, you can use the client feature of zope
to go snarf the web page and then extract what you need (hope you have
permission :)

If some other mechanism can write them to a file, you can suck them up
with an external method whenever someone asks for it.

-------

For doing things periodically there's the ZScheduler product
(http://www.zope.org/Members/lstaffor/ZScheduler). The product is in 
it's alpha development stage, but if you employ it cautiously, you may 
find that it works for you.

For getting the exchange-rate data, it depends on where it's coming 
from. Give us some more details and perhaps we can help better.

You might want to use ZClient (see the How-To at
http://www.zope.org/Members/lstaffor/ZClientMethod).

There's also the SiteSummary product
(http://www.zope.org/Members/edmundd/SiteSummary/).

If you don't have too much traffic on your site, you can let the "first 
user of the day" be responsible for triggering new values to a db/file 
using the ZopeTime function.

Something like this maybe:
IF (SELECT day FROM currencytable == ZopeTime(day)):
        SHOW FROM DB
ELSE:
        START THE COLLECTORS SCRIPT
        AND PUT IN THESE VALUES IN THE DB


-------------------------------------------------------------
Is there a way I can grab the time value on my current system that Zope is running on with a MILLISECOND precision?
http://www.faqts.com/knowledge-base/view.phtml/aid/4964
-------------------------------------------------------------
Fiona Czuczman
Shane Hathaway

Works on 2.2.0:

<dtml-var expr="_.DateTime().millis()">


-------------------------------------------------------------
I'm running ZOPE with administrator privileges, when I try to create any objects I get an error message.
http://www.faqts.com/knowledge-base/view.phtml/aid/4968
-------------------------------------------------------------
Fiona Czuczman
waldemar

Error Message:

Zope Error

  Zope has encountered an error while publishing this resource.

  Error Type: SuperCannotOwn
  Error Value: Objects cannot be owned by the superuser

Answer:

Read the error.  You have to create another user besides the 
administrator, then logon as the new user and you can create objects.


## Edited Entries ##############################################


-------------------------------------------------------------
I want to update from Zope 2.1.6 to 2.2.0. Is there a way to copy my contents to the new version or do I have to start from the beginning?
http://www.faqts.com/knowledge-base/view.phtml/aid/4778
-------------------------------------------------------------
Fiona Czuczman
ethan mindlace fremen

two ways:

1. Copy your Data.fs from the var directory of the old zope into the new
one.  Remember that you need to have the right products installed.

2. Switch to INSTANCE_HOME usage, as explicated by Evan:

http://www.zope.org/Members/4am/instancehome

I add the steps of symlinking the software folder to something like
zope_soft. This has the advantage that any further releases of zope, to
upgrade you simply unpack and compile zope, then link it's folder to
zope_soft, restart zope, and (more-or-less) viola!  things work.


-------------------------------------------------------------
Does Zope have a version that runs well with Windows 2000 server?
http://www.faqts.com/knowledge-base/view.phtml/aid/3518
-------------------------------------------------------------
Fiona Czuczman, Gijs Reulen
Wolfgang Strobl

I haven't had any difficulties running 2.1.6 on Windows 2000, so far. I
tried it on both Win2000 prof US and Win2000 Server Ger.

Currently, July 17th 2000, there are some problems with running Zope 
2.20: the database connections have permession errors.


-------------------------------------------------------------
Is there documented anywhere, simple instructions for creating a full site search by keyword?
http://www.faqts.com/knowledge-base/view.phtml/aid/4776
-------------------------------------------------------------
Fiona Czuczman
ethan mindlace fremen

You want the ZCatalog Howto:

http://www.zope.org/Documentation/How-To/ZCatalogTutorial


-------------------------------------------------------------
Using dtml how can I cat the values of parameters, all strings, in a form to another parameter in the same form?
http://www.faqts.com/knowledge-base/view.phtml/aid/4775
-------------------------------------------------------------
Fiona Czuczman
Aaron Williamson

I tested using this:

<dtml-call "REQUEST.set('foo','this is a string')">
<dtml-call "REQUEST.set('bar','so is this')">
<dtml-call "REQUEST.set('foobar',foo+bar)">

and it worked, so I guess you could just use

<dtml-call "REQUEST.set('all_params', param1+param2+etc...>


-------------------------------------------------------------
How to access methods or queries in the parent's parent's parent's subfolder?
http://www.faqts.com/knowledge-base/view.phtml/aid/4780
-------------------------------------------------------------
Fiona Czuczman
Chris McDonough

Problem:
Root
-----Folder1
----------Sub1
--------------My_Qry
----------Sub2
---------------otherfolder
--------------------How_to_access_My_Qry_from_Sub1????

is there <dtml-var parent.parent..... type thing??? or do you have to 
call the parentobject method and assign it to some object before getting 
to it?

Solution:

Try,

<dtml-var "Sub1.My_Qry()">

If you need to pass arguments to My_Qry:

<dtml-var "Sub1.My_Qry(arg1='val1', arg2='val2')">