Although you can generate by code contents with an id that starts with underscore, like "_foo" it seems that you can't traverse an item with this special id.
Every attempt to access a content named that way using a browser lead to a NotFound error. Neither methods like __bobotraverse__ or __getitem__ are called, like if this limitation is checked very early.
How this limitation works and how can I change it? Can I access subobjects with a prefix underscore in the id?
Found inside the unrestrictedTraverse implementation from OFS.Traversable:
if name[0] == '_':
# Never allowed in a URL.
raise NotFound, name
...but this is not enough. There's another check similar to the ones notified by #Mathias inside ZPublisher.BaseRequest.DefaultPublishTraverse in the publishTraverse method.
if name[:1]=='_':
raise Forbidden("Object name begins with an underscore at: %s" % URL)
The sad part is that is not simple to override this:
the unrestrictedTraverse is called on the Plone site context (so I can't customize it only for my content type)
the publishTraverse method is owned by the request implementation (maybe for this I can use ad custom publish traverser?)
The simplest way to fix this seems through monkeypatch.
Related
So I have to use a specific variable name (g-recaptcha-response) in my form post in order to pass a captcha process using google recaptcha V2. The thing is eslint will always complaint about the variable name wit the error "Parsing error: Const declarations require an initialization value". I know the problem it's because of the hyphenated name convention but I can't find anywhere the way to bypass this rule and I have to use that name since it's a re-captcha parameter that needs to be send with the form.
const g-recaptcha-response = await this.$recaptcha.getResponse(),
I need to make something like that work within an eslint /& vue-3 template with composition API, any feedback will be really appreciated.
I'm creating several commands programmatically and want to avoid having to add key mappings for them explicitly in keymap.cson.
The Flight Manual page for Keymap Manager shows an add method. It doesn't give an example of how to actually use this method, so my guess is that this should work:
atom.keymaps.add('atom-text-editor',{'alt-1':'custom:my-command'});
However, this does not appear to work. When I run this in the developer console, I get this message:
Encountered an invalid key binding when adding key bindings from 'atom-text-editor' 'custom:my-command'.
I got this message even if I changed alt to ctrl.
What does the correct method call on atom.keymaps look like.
I agree, the docs are not detailed enough. However, through trial and error, I managed to figure it out:
atom.keymaps.add('foo', {
'atom-text-editor' : {
'alt-1': 'custom:my-command',
'#': 'application:about'
// etc
}
});
Explanation:
atom.keymaps.add(source, bindings, priority);
The source argument is not the same as what is referred to as the selector in Atom speak. Instead, it's an identifier that can be used to remove the keybindings, should you wish to (except it seems they haven't actually implemented a remove method!).
Instead, the selector should go inside the bindings argument, as shown above.
Is there a simple way to check if a content-type, or a specific object, has Versioning enabled/disabled in Plone (4.3.2)?
For context, I am making some unique conditionals around portal_actions. So instead of checking path('object/##iterate_control').checkout_allowed(), I need to first see if versioning is even enabled. Otherwise, the action in question does not display for items that have versioning disabled, because obviously it isn't checkout_allowed.
I didn't have any luck with good ole Google, and couldn't find this question anywhere here, so I hope it's not a dupe. Thanks!
I was able to get this working by creating a new script, importing getToolByName, and checking current content type against portal_repository.getVersionableContentTypes(). Then just included that script in the conditional.
I was looking for something like this that already existed, so if anyone knows of one let me know. Otherwise, I've got my own now. Thanks again!
The first thing that checkout_allowed does is check if the object in question supports versioning at all:
if not interfaces.IIterateAware.providedBy(context):
return False
(the interface being plone.app.iterate.interfaces.IIterateAware:
class IIterateAware( Interface ):
"""An object that can be used for check-in/check-out operations.
"""
The semantics Interface.providedBy(instance) are a bit unfortunate for usage in conditions or TAL scripts, because you'd need to import the interface, but there's a reversal helper:
context.portal_interface.objectImplements(context,
'plone.app.iterate.interfaces.IIterateAware')
Is there a way to open a specified document, eg "production order 123" or form, eg "purchase orders" in Ax2012 from an external application directly?
In detail, I'm looking for something similiar like AXPath, but this doesn't work with versions greater then 2009.
Is there any ( maybe included ) way to achieve this?
There is! It's using AX's drilldown functionality which uses AxHLink.exe to handle dynamics:// URLs, which are passed to the Classes\SysStartupCmd function. You could also create some custom code there if you wanted to launch the AX client executable directly.
My question I asked some while back should have a great deal of useful information in it here:
What handles dynamics:// URLs?
Some more can be found: http://technet.microsoft.com/en-us/library/aa834337.aspx
EDIT:
It sounds like you are confused or the posts weren't clear enough. I think you have 3 basic options.
Dynamics:// URLs are handled by AxHLink.exe and they only seem to handle drilldown, viewalert, and viewalertrule. So if you want to use Dynamics:// URLs, you will need to hi-jack those somehow. There is a pastbin from Jan in that other stack post.
Create a custom URI handler and event poller (lot of work) see http://axcoder.blogspot.dk/2010/10/how-to-open-form-in-running-ax-from.html
Extend SysStartupCmd and then instead of using Dynamics:// URLs, just call Ax32.exe -startupCmd directly and a parameter can be passed to your custom class.
What is the most sraightforward (but not very hackish - unPlonish) way to create a "page" in Plone (v 4.x), which would show some Plone internals info? I'd like to generate a page document, which would paste dir() (or whatever my own function) result to <pre/> or something like that. Straightforward.. i mean, without having to create a Plone product or having to modify server files directly - just using ZMI..
You want to install plone.app.debugtoolbar
http://pypi.python.org/pypi/plone.app.debugtoolbar/
which gives you access to the most imporant informations about the current context object, request data etc.
Products.DocFinderTab adds a "Doc" tab in the ZMI that allows you to explore the current object and its methods. If you installed with the Unified Installer and use the "develop" configuration, it's already loaded.
Products.Clouseau may still work with recent Plone's, though it's aging. It gives you an AJAX interface to explore the context from within Plone.
Finally, to explore the request object, you may just add:
<div tal:replace="structure request" />
to a template. That will allow you to check all the HTTP and form variables as well as what's stored in the request.
Go to the ZMI, add a "Script (Python)", and define your function dir() and print the result like this :
print dir()
return printed