I need to store inside plone.app.registry binary data in a way compatible from Plone 3.3 to 4.2.
Using simply a schema.Byte type I'm able to quickly reach this on Plone 4.2 (not very user friendly, but it works), but not on Plone 3.3.
On Plone 3.3 the registry is displyaing a file upload control, but when I try to get the saved data I found that it simply stored a string like:
'<... HTTPFileUpload...>'
...so a python repr of an object.
How can I fix this? I need to use plone.namedfile product with collective.z3cform.filewidget?
plone.app.registry is not really designed to store binary data. It is designed to be simple, lightweight and migration-proof.
What are you trying to achieve with this? There is probably a better way.
Since plone.formwidget.namedfile 1.0.12 you can use that wigets on ASCII fields also. Data is then converted to base64. Plone 5 uses that feature for it's site logo, which is stored in the registry.
For an example, see the Plone 4 backport of that feature: https://github.com/collective/collective.sitelogo
Especially:
Usage of an ASCII field for your image: https://github.com/collective/collective.sitelogo/blob/master/src/collective/sitelogo/interfaces.py#L14
Changing the controlpanel widget for the ASCII field to NamedImageFieldWidget: https://github.com/collective/collective.sitelogo/blob/master/src/collective/sitelogo/controlpanel.py#L19
Ok, seems that you can have the same behavior also on Plone 3; in only needed an upgrade of plone.z3cform
Related
I am working on AEM 5.6 to 6.2 upgrade project. There are some nodes in aem 5.6 environment which contains invalid character(as per JCR naming convention like rte[2] is one of the node name which doesn't follow the naming convention)but somehow we are able to replicate those nodes in 5.6 environment. After upgrade it to aem 6.2,it seems like JCR is more restricted and won't allow the nodes to replicate if it is having invalid characters.
Getting the below error in aem 6.2: error:
com.day.cq.replication.ReplicationException: Repository error during node import: Cannot create a new node using a name including an index
Is there any way we can configure AEM 6.2 to stop checking JCR node names?or any other solution?
JCR 2 does not allow [ as a valid character therefore you won't get an easy workaround for this. It's one of the limitations just like the same-named-sibling.
My recommendation will be to modify these nodes before the upgrade/migration to 6.2. This can be complicated and costly for business but 6.2 won't allow it.
As a background [ was allowed in older version due to twisted support for grammar syntax for same-named-siblings.
Assuming that these are all content nodes as nothing out-of-the-box in AEM 5.x follows this naming convention.
Some ways to fix it:
Write a custom servlet to query and rename the paths across all references. You will have to test your content for these renames.
Use Groovy console (https://github.com/OlsonDigital/aem-groovy-console) to rename the nodes.
In either case, you will need to modify the nodes before the migration as the structure is not oak compliant therefore you cannot use crx2oak commit hooks also. This can be done with both in-place upgrade and side-by-side migration. This is similar to the problem with same named siblings that must be corrected before the migration.
Some efficiency techniques that might help:
Write queries to find invalid node names on top-level nodes like /content/mysite-a, /content/mysite-b etc. Don't run root level queries on /content as it might downgrade to
traversal and halt the execution.
Ensure that all references are updated in same commit. If you are using custom servlet, call session.save() only after updating all the node names and it's corresponding references.
As i mention in the comment this replication failure causes because of the oak workspace restriction as the code snippet below
//handle index
if (oakName.contains("["))
{ throw new RepositoryException("Cannot create a new node using a name including an index");
}
and i feel you can't escape this constraint as it it required by the repository to maintain consistency
you can find nodes that ends with '[', by below query
SELECT [jcr:path] FROM [nt:base] WHERE ISDESCENDANTNODE('/content/path/') AND [jcr:path] like '%\['
and to modify the JCR/CRX nodes you can use CURL or SlingPostServlet method
Some helpful posts are blow.
https://github.com/paulrohrbeck/aem-links/blob/master/curl_cheatsheet.md
http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html
Can you try migrating using a tool like oak-upgrade and let us know if you are still facing this issue.
The tool is robust and you have the flexibility to configure specific sub-trees for migration using this tool.
I want to update inventory based on sku.
For example
php magento update_inventory --sku&quantity=array(1001,10) --sku&quantity=array(1002,20) --sku&quantity=array(1003,30)
But I’m not getting how to add options/arguments ?
here user at least need to provide one pair (sku& quantity).
for this i think i have to use ArrayInput class/InputArgument/InputOption.
Can you give some solution or reference to above requirement?
Have you looked at how Magento\Setup\Console\Command\AdminUserCreateCommand uses options? Take a look at how that code uses getOptionsList in the configure method. For your use case you may want to look into using InputOption::VALUE_IS_ARRAY
A good reference will be http://symfony.com/doc/current/components/console/introduction.html#using-command-options
You may also want to consider a different input format. For example using arguments instead of options and specifying the format in documentation.
php magento update_inventory 1001:10 1002:20 1003:30
I'm trying to import some content from a CSV into Drupal 7. I've tried the Feeds module but it doesn't allow me to match fields to my content type—as far as I can tell—which is a problem.
Previously—in Drupal 6—I have used Node Import but this isn't supported in Drupal 7. Any suggestions?
The feeds module will work, you just need to do a title work.
Create a new importer at admin/structure/feeds/create
Change your Parser settings to use CSV
Check the CSV Parser settings once saved and make sure the correct delimiter is selected
Select "Node Processor" as your processor in your Processor type
Verify your Processor settings. Select your content type. It is important to set a user for for the node author. There is currently a bug that will cause an error if the author is set to anonymous.
Using the column names in your CSV map your columns to your Drupal 7 fields.
Finally, go to /import and run your feed import.
That should do it for you.
Migrate is very robust and can do all kinds of importation.
For very simple things feed is certainly enough.
I'm quite new to Plone and as you can read in the Title line I'm working with Plone 4.
Despite being new to both plone and Python, I've managed to get a fully working page to send rich text mail messages to user-selected members of my web site.
What I've done is basically clone (i.e. copy and rename) the sendto, sendto_form, and sendto_template and editing them in order to get what i needed.
As I've said it works quite fine but I need to add a CC recipient, but the MailHost.send() method does not allow for a CC header (and though the secureSend method allows for it, it is a deprecated method in Plone 4).
I've also used a template to let the user add an attachment, the template is available at How to send mail with attachments in Plone using a template approach?.
I know that the python email.Header function does exactly what I need, but when I try to import the library I get an insufficient privileges error (I'm logged in as admin).
I've also tried to work around it by using the following approach:
templ="""Subject: %(subject)s
From: "%(send_from_name)s" <%(envelope_from)s>
To: %(send_to_address)s
CC: %(send_cc_address)s
Content-Type: text/html; charset=UTF-8
Reply-To: %(send_from_address)s
%(comment)s
--
%(signature)s
"""
message=templ % variables
context.MailHost.send(message.encode("utf-8"),encode="quoted-printable")
It works almost fine but can't accept accented characters (which are very common in Italian language).
Any ideas?
Thx in advance,
Luca
You're reaching the limits of the secure python scripting environment you can use TTW in plone. The email module is not allowed to be imported in this type of script.
The old secureSend method on the MailHost object used to have an method parameter for cc which seemed to have been removed in the latest version which only has a "send" method and no cc parameter.
This means you'll have to move the code to a product on the file system in a view in order to use the cc part.
How do you change the QTY (quantity) label in UberCart (in Drupal) without actually hacking the core components? I want the label to be be months, instead of qty.
You could use the String Overrides module. Here is an excerpt from its project page:
Provides a quick and easy way to replace any text on the site.
Features:
Easily replace anything that's passed through t()
Locale support, allowing you to override strings in any language
Ability to import/export *.po files, for easy migration from the Locale module
Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
I once ran into a similar issue with Ubercart in another language (German), and we "solved" it by re-translating the string. The mentioned module should do the trick in your case.
I haven't used ubercarts, but I would guess there would be an admin section to do that. Else hook_form_alter() or hook_form_FORM_ID_alter() should be able to do the trick for you.
Unfortunately, there is no setting for this in ubercart.
Doing a search for 'Qty' (case sensitive, as there are numerous 'qty' in code) in the current ubercart-6.x-2.0-rc7 release gives seven matches:
3 in theme functions, which you'd need to override in your theme
1 in a form definition, which you'd need to change via hook_form_alter as googletorp suggested
3 in table definitions, which you'd need to change via hook_tapir_table_alter and/or hook_tapir_table_header_alter (see the hooks.php file in ubercarts doc directory for these)
So you should be able to implement your changes without changing the module itself, but given the amount of work involved, I'd try schnecks suggestion first ;)