Re: [Zope] Help - Python

2001-01-24 Thread J M Cerqueira Esteves

Ol :)

On Tue, Jan 23, 2001 at 08:56:34PM +, Paula Mangas wrote:
 I'm a newbie and i would like to know how can i create a DTMLDocument from
 a Python method.

Here is a short example of document creation (with a few other tips), 
assuming it's in a Python method with parameters (self, REQUEST):

#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 

# ...

# The following refers to folder  "/farm", in a virtual host 
# supported by SiteRoot.
farm = REQUEST.PARENTS[-2].farm
# `farm' now refers to the folder object.
# And this is a subfolder, "/farm/the_ducks"
the_ducks = farm.the_ducks
# This just reads the id for a new document from a submitted form,
# using a default value if no `duck_id' was sent.
id = REQUEST.get ('duck_id', 'new_duck_in_town')

duck_notes = ...
some_title = ...
some_colour = ...

# This creates the document (under "/farm/the_ducks"), assuming you have 
# defined some string, `duck_notes', holding the initial content for it:
the_ducks.manage_addProduct['OFSP'].manage_addDTMLDocument (id, 
file = duck_notes)
# This changes the document's title (it already had an empty one by default).
the_ducks[id].manage_changeProperties ({'title': some_title})
# And this adds a property of type `string'.
the_ducks[id].manage_addProperty ('colour', some_colour, 'string')
#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 

Look for some API documentation in Zope's internal help and on the Web.
Browsing Zope sources may also be most helpful...

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




[Zope] Python Methods 0.1.7 under Zope 2.2.1

2000-09-17 Thread J M Cerqueira Esteves

Working with Zope 2.2.1 (in two distinct servers), I noticed the following
behaviour with (0.1.7) Python methods (created under Manager role):

1. Apparently anyone (non-authenticated users) can successfully run the 
   methods even if these include operations (folder/file/user creation, etc.)
   for which the invoking user has no permission.

2. Although I am able to give Python methods the proxy role of Manager,
   I can not give them other proxy roles, roles which I also have and
   am able to give to DTML methods, for instance (anyway, problem 1
   makes privileged proxy roles superfluous... :) ).

Has anyone fixed this (while we wait for the new shiny Python methods)?

Best regards  thanks in advance 
   J Esteves

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] Backslash as line continuation in C (Unix)

2000-09-13 Thread J M Cerqueira Esteves

On Tue, Sep 12, 2000 at 09:45:53PM -0700, Hung Jung Lu wrote:

 I am trying to build a third-party utility in Linux. I ran into troubles in 
 the compilation process because of the usage of backslash \ as line 
 continuation. (This is used in #def preprocessor macro statements.) When I 
 remove the backslashes and join the lines, it compiles fine. (I know 
 backslashes are fine in Windows Visual C++.)

Do the lines really END with a backslash?  There should be no problems
with standard C constructs, but for the backslash to work as expected it
really must be the last character in the line; there must be no white
space characters after it.  If your files are properly processed by some
Windows compiler and have problems under Linux, I can think of two
explanations:

Either the Windows compiler is being "tolerant" with improper white
space after the "\"...

Or your source files get white space after the "\" only when transported
to Linux; this may happen if under Linux the lines of your source files
still end with CR-LF (carriage return, line feed) as they do in Windows, 
instead of only LF (the expected end of line character in Unix).  

For all the other lines, perhaps the compiler doesn't care about the
extra CRs (they just count as white space), but they may become critical for
line continuation: where you are expecting a line to end with "\", your
Linux compiler may in fact see

   \ CR LF [the last (pre-LF) line character is CR, not "\" as expected]

instead of the proper sequence
   
   \ LF[the last (pre-LF) line character is "\", marking continuation]

If you have in Linux a small program called "fromdos", try to convert
your source files with it; the same conversion of line endings can
also be easily made with "tr", for instance.

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] NEWBIE HELP can not get Zope to start

2000-09-08 Thread J M Cerqueira Esteves

On Thu, Sep 07, 2000 at 10:12:16PM -0400, Douglas Eadline wrote:

 6. OK, I'll add a user. I go to acl_users and add a user.

Did you give it the "manager" role?


Best regards
  J Esteves
-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] 2.2.1 and zdiscussion

2000-08-26 Thread J M Cerqueira Esteves

Hi

On Sat, Aug 26, 2000 at 12:20:29PM +0800, Bak @ kedai wrote:
 hi
 a clean install won't start properly  with ZDiscussion product install.  the 
 same thing also with ZDiscussion based classes created.

There is a missing comma in the definition of __ac_permissions__ in class
ZDItem (file ZDiscussions.py):

__ac_permissions__ = ( 
('Manage properties', ('manage_addProperty',
   'manage_editProperties',
   'manage_delProperties',
   'manage_changeProperties',))
)


Just add a comma before the last parenthesis:

__ac_permissions__ = ( 
('Manage properties', ('manage_addProperty',
   'manage_editProperties',
   'manage_delProperties',
   'manage_changeProperties',)),
)

In this way, __ac_permissions__ becomes a tuple of permissions (one, in
this case), as it should be.

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




[Zope] Broken ZDiscussions-0.5.3 on 2.2.1b1: missing comma...

2000-08-21 Thread J M Cerqueira Esteves


I tried to install ZDiscussions (ZUBB) 0.5.3 it on a Zope 2.2.1b1 and got 
a broken product. The traceback I got at Zope startup was:

2000-08-21T01:44:09 ERROR(200) Zope Couldn't import Products.ZDBase
Traceback (innermost last):
  File /usr/local/lib/Zope-2.2.1b1/lib/python/OFS/Application.py, line 396, 
  in import_products (Object: string)
  File /var/lib/zope/an/Products/ZDBase/__init__.py, line 86, in ?
  File /var/lib/zope/an/Products/ZDBase/ZDiscussions.py, line 106, in ?
  File /usr/local/lib/Zope-2.2.1b1/lib/python/App/class_init.py, line 109, 
  in default__class_init__  (Object: ZDItem)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/AccessControl/Permission.py, 
  line 204, in registerPermissions
ValueError: unpack sequence of wrong size


The problem seems to be a missing comma in the definition of__ac_permissions__
in class ZDItem (file ZDiscussions.py):

__ac_permissions__ = (
('Manage properties', ('manage_addProperty',
   'manage_editProperties',
   'manage_delProperties',
   'manage_changeProperties',))
)

Since this is lacking a comma before the last parenthesis, 
outer parentheses are "dropped" and it becomes as a two-element tuple:
  ((X,methods))  -  (X,methods)
that is, a "naked" permission, instead of the intended one-element (one
permission) tuple ((X,methods),).

In fact, ac_permissions_ was already defined like this in ZDiscussions-0.2.0...

I wonder if this was clearly noticed before 2.2.1b1, since line 204 of
Permission.py (see traceback above) belongs to a new function called
`registerPermissions'.  This function begins with

for setting in permissions:
if _registerdPermission(setting[0]): continue
if len(setting)==2:
perm, methods = setting
default = defaultDefault
else:
perm, methods, default = setting
_registeredPermissions[perm]=1

and with the bug above, its easy to see the mess resulting when `permissions'
has the above __ac_permissions__ value.


Apart from this, is ZDiscussions (ZUBB) 0.5.3 fully compatible with
Zope 2.2.1?  I just restarted Zope after adding the comma and the
product is no longer broken.  Perhaps I can do some testing now...

Best regards
-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




[Zope] Another permission mapping error... [still ZDiscussions 0.5.3]

2000-08-21 Thread J M Cerqueira Esteves

On Mon, Aug 21, 2000 at 05:03:37PM +0200, Wolfgang Strobl wrote:
 I just tried installing a freshly downloaded copy of 
 YihawDirectory.zexp into a relatively new 2.2.1b1, but in vain.
 
 snip
 Error Type: Permission mapping error
 Error Value: Attempted to map a permission to a permission, 
 Add Yihaw Objects, that is not valid. This should never happen. (Waaa). 
 snip

I've also met a "permission mapping error" in 2.2.1b1... After correcting the
ZDiscussions comma bug mentioned before, I tried to import
ZDiscussions.zexp, continuing the installation process, and got:

Error Type: Permission mapping error
Error Value: Attempted to map a permission to a permission, Add
ZDiscussions Items, that is not valid. This should never happen.
(Waaa). 

with the following traceback:

Traceback (innermost last):
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZPublisher/Publish.py, line 222, i
n publish_module
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZPublisher/Publish.py, line 187, i
n publish
  File /usr/local/lib/Zope-2.2.1b1/lib/python/Zope/__init__.py, line 221, in zpu
blisher_exception_hook
(Object: Traversable)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZPublisher/Publish.py, line 171, i
n publish
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZPublisher/mapply.py, line 160, in
 mapply
(Object: manage_importObject)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZPublisher/Publish.py, line 112, i
n call_object
(Object: manage_importObject)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/OFS/ObjectManager.py, line 508, in
 manage_importObject
(Object: Traversable)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/OFS/ObjectManager.py, line 263, in
 _setObject
(Object: Traversable)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/OFS/ObjectManager.py, line 271, in
 manage_afterAdd
(Object: Traversable)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/ZClasses/ZClass.py, line 422, in m
anage_afterAdd
(Object: ZDTopic)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/OFS/ObjectManager.py, line 271, in
 manage_afterAdd
(Object: Traversable)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/App/Factory.py, line 144, in manag
e_afterAdd
(Object: RoleManager)
  File /usr/local/lib/Zope-2.2.1b1/lib/python/AccessControl/PermissionMapping.py
, line 137, in manage_setPermissionMapping
(Object: RoleManager)
(Info: (['Access contents information', 'Add BTree Folders', 'Add Database M
ethods', 'Add Documents, Files, and Images', 'Add Documents, Images, and Files',
 'Add External Methods', 'Add Folders', 'Add MailHost objects', 'Add SiteRoots',
 'Add User Folders', 'Add Versions', 'Add Vocabularies', 'Add Z Gadfly Database 
Connections', 'Add ZCatalogs', 'Add Zope Tutorials', 'Change DTML Documents', 'C
hange DTML Methods', 'Change Database Connections', 'Change Database Methods', '
Change External Methods', 'Change Images and Files', 'Change Versions', 'Change 
configuration', 'Change permissions', 'Change proxy roles', 'Create class instan
ces', 'Delete objects', 'Edit Factories', 'FTP access', 'Import/Export objects',
 'Join/leave Versions', 'Manage Vocabulary', 'Manage Z Classes', 'Manage ZCatalo
g Entries', 'Manage properties', 'Manage users', 'Open/Close Database Connection
', 'Open/Close Database Connections', 'Query Vocabulary', 'Save/discard Version 
changes', 'Search ZCatalog', 'Set Access Rule', 'Take ownership', 'Test Database
 Connections', 'Undo changes', 'Use Database Methods', 'Use Factories', 'Use mai
lhost services', 'View', 'View History', 'View management screens'], 'Add ZDiscu
ssions Items', 0))
Permission mapping error: (see above)

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] Your feedback: what should DateTime strftime() behavior be?

2000-07-27 Thread J M Cerqueira Esteves

 
  +1


-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




[Zope] image inclusion: empty ALT not the same as no ALT

2000-06-23 Thread J M Cerqueira Esteves

Greetings

I just noticed a problem with the `tag' method:

If I insert an image with 

  dtml-var "some_image.tag (border='0', alt='')"

(nice because `width' and `height' are inserted automatically), I get an
img element with NO `alt' attribute, instead of an `alt' atribute with
an empty string as its value (alt="").  

An empty `alt' value is important when using images for which it is best
not to insert any alternative text in text browsers (decoration-only or
redundant image links, for instance), because the absence of the `alt'
attribute may not be equivalent to an empty value.  In lynx, for example,
the file name of the image (more precisely, the last component of the
path in the `src' attribute) is shown (yuck) when no `alt' attribute is
supplied.

--
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] Virtual host admin under Apache+ZServer+SiteAccess

2000-06-02 Thread J M Cerqueira Esteves

On Fri, Jun 02, 2000 at 09:02:11AM +0100, Phil Harris wrote:
 
 Try going to http://localhost:8080/__no_before_traverse__/manage
 

Oops, I should have re-read SiteAccess docs...  Thanks.

After a few tests it seems to work normally except for one feature:

When managing through http://localhost:8080/manage I can see
the full list of transactions with "Undo", but when managing through 
http://localhost:8080/__no_before_traverse__/manage, "Undo" only 
shows me the list of transactions made while operating that way
(with __no_before_traverse__).  Usually not a problem... unless
there are nasty side effects I am unaware of.


 J Esteves (still a newbie in most Zopish matters...)

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




Re: [Zope] Two issues for Z2.2: XHTML malicious tags

2000-06-02 Thread J M Cerqueira Esteves

On Fri, Jun 02, 2000 at 06:50:46PM +0200, Alexander Limi wrote:
 1. The HTML that Zope outputs is not very standards-compliant (XHTML 1.0) at
 the moment. Tags like img / are rendered as IMG etc. I would like to

Perhaps support for XHTML-compliance in Zope should be optional.  I
wrote a few pages in XHTML some time ago, had no problems with
Netscape 4.xx, but was later informed of a few problems by some users.
Some still abundant browser versions were particularly not grokking
(and thus showing the user) the processing instruction

  ?xml version="1.0" encoding="ISO-8859-1"?

For generally accessible pages, I'm therefore still using HTML 4.0.

This is mentioned on http://www.w3.org/TR/xhtml1/:

 Be aware that processing instructions are rendered on some user
 agents. However, also note that when the XML declaration is not included
 in a document, the document can only use the default character encodings
 UTF-8 or UTF-16.

Anyway, tags like img / are considered valid HTML 4.0 by the W3C validator,
so they would not cause validation "noise" for those still using HTML 4.0.

-- 
 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/

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




[Zope] Virtual host admin under Apache+ZServer+SiteAccess

2000-06-01 Thread J M Cerqueira Esteves

On Thu, Jun 01, 2000 at 06:18:25PM -0600, ethan mindlace fremen wrote:
 o Some basic hooks to support virtual hosting (a la
   SiteAccess) have been designed and will be added 
   to allow product authors to write virtual hosting 
   support without fragile dependencies on parts of
   the Zope core.

Greetings

For security reasons, I would like to do web administration of remote Zope
installations via ssh port forwarding.  For instance, while running

  ssh -g -L 8080:foo.bar:8080 foo.bar

one can access a ZServer on foo.bar:8080 using  http://localhost:8080/.

However, I'm using Apache with ZServer and SiteAccess for virtual
hosting as documented in http://www.zope.org/Members/anser/apache_zserver, 
and this has a nasty implication: once I activate a SiteRoot inside some
Zope folder "/parrot" for making it the top folder of a virtual host
http://parrot.bar/, the use of URLs under http://parrot.bar/ is forced
whenever administering content under the "/parrot" folder, even if
arriving from a foo.bar:8080 document: the browser is then no longer
connecting through the secure channel but talking directly with
http://parrot.bar/.  Of course this could also be redirected, but not so
easily.

In this example, it would be nice to be able to administer the contents
of http://parrot.bar/ either via parrot.bar (typically for less
sensitive content, end users) or via foo.bar:8080 (more delicate
administrative tasks, administrators which know how to encrypt
communication with ssh).  Is there interest (or is it feasible) to make
virtual hosting support evolve to allow this?  (I didn't think much
about the implications, but can already notice a problem under the
virtual hosting strategy above (ZServer+Apache): how to make Zope
"guess" if it should write absolute URLs for parrot.bar or for foo.bar:8080?)

Even better would be web content administration under SSL, of course :)

 jmce: +351 919838775 ~ http://artenumerica.com/ ~ http://artenumerica.org/


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