Define __before_publishing_traverse__

I would like to override the before_publishing_traverse method in zope. I read the documentation, but I couldn't find anything on the subject.
I tried to do like PUT_factory, create a script in Extensions, but to no avail. Can someone help me?
Thank you

What problem are you trying to solve? Using ExternalMethod is deprecated since ages.

Traversal is documented here: Requests and traversal — Plone Documentation v4.3

First state your problem, then let's talk about options.

thank you,
So here is what I would like to do. If you know Django, I would like to reproduce Django's url system, ie pass url parameter values in the url.
ex: my_site / <int: id> / user would match mysite / 123456 / user where 123456 is the value of id
Currently, I don't believe Zope can do this directly !?
So, I thought to overload before_publishing_traverse to do the necessary processing before going through bobo_traverse.
Do you think it's possible?

Zope is open source. Thus, you have the option to search its code.

In this specific case, you will find __before_publishing_traverse__ in ZPublisher.BaseRequest (the implementation) and ZPublisher.BeforeTraverse (important application). There are related tests which you can use as usage examples.

Zope used to support so called "access rule"s -- nowadays, they might be available in a separate product (likely called Products.SiteAccess). "Access rules" are a major application of BeforeTraverse (and thereby of __before_publishing_traverse__). They allow you to look at the url, either for inspection/rejection or for modification. Note that in order to change the effective url, you must change internal variables of the request object (which contain the preprocessed url for traversal purposes) -- look at BaseRequest.traverse for details.

If all you want to do is create nice URLs using path components instead of a query string, you may access REQUEST['traverse_subpath'] in a simple Script (Python), like so:

ts = request['traverse_subpath']
uid = int(ts[0])
return context.user_html(uid)
return context.normal_index_html

It's just a bit unusual that this would be your index_html... have fun!

An option is to create a browser view that implements IPublishTraverse. Example from standard Plone is how the download of files is handled:

Another option is to register a traverser. For example, Plone registers a traverser for the Zope site root so if a browser visits this root we display a page plone-overview instead of the default (index_html). See the Python part and the zcml part.

Plone Foundation Code of Conduct