zmi: duplicates in add products list - zope

I have an old-style product with several classes. In the class, I have defined the meta_type and I have also registered them in __init__.py, i.e.:
def initialize(context):
context.registerClass(
ClassA.ClassA,
permission = "Add ClassA",
constructors = (ClassA.manage_addClassA,
ClassA.manage_addClassA),
icon = 'www/images/ClassA.gif'
)
This worked fine until I updated my Zope from 2.9 to 2.13. Now in the zmi, in the "Add Products" dropdown list, these meta_types are shown two times each.
I tried to track the source of this error:
ObjectManager.py, filtered_meta_types
ObjectManager.py, all_meta_types
getattr(Products, 'meta_types', ())
Now I don't know where to look next :)
It's only a nuisance, it does not cause any problems in the functionality of the product. Maybe I should update it to a new-style zope product, but I'm curious where this error comes from.

You need to remove your <five:registerPackage /> registration from the configure.zcml file, because your legacy package is using the Products. namespace.
The Products. namespace has always been auto-loaded; the initialize(context) function is implicitly being loaded for that namespace since before it was an official namespace.
When Zope started to support packages outside of the Products. namespace, however, the decision was made (wisely) to make registration explicit instead, and the <five:registerPackage /> was introduced to let you use the old registration hook if you still needed it.
In your case, however, that means your initialize() function is being called twice; once because it is a Products. package, and once because you explicitly registered it.

Related

Link two DOOR's modules without programming

I am new with IBM DOORS and I need some hint or help with this, probably, basic issue.
I have a Module A which contains some requirements and another Modules B,C,D etc, which corresponds to a concrete supplier answering to requirements that come from Module A. Therefore, if a requirement changes (i.e the text) I would like that automatically that change is also shown in modules B,C D...
Module A (Atributes)
Req_code (text)
Req_type
Req_text
Req_owner
[...]
Module B,C.. (Atributes)
Req_code (text)
Supplier
Base_option
Req_answer
Req_comments
[...]
The idea is, somehow, to make a linkage between Req_code in Module A and Req_code from other modules (one to many) so I can create a complete view with atributes from two modules.
I have been searching on the web but I have only found that this could be done with a dxl script. Is there any other way to do this not involving programming? I tried creating a linkage module, but I did not get what I wanted.
Thanks in advance,
Bilbinight
I think what you want is actually the companion of link-by-attribute; Link > Advanced > Create links..., but first lets do a little architecture creation.
I am assuming that B, C, etc. will be creating answers to A and, as such, will be doing the linking to the objects in A as they answer. With this information, we can create Module A with Req_code (use "Object Identifier"), Req_type (Type:string or enumerated list), Req_text (Use "Object Text"), Req_owner (Type:string), etc.
Similarly, create Modules B and C with such attributes as necessary to describe the information to be contained in them. finally create a link module "L" to contain the Link Sets for B->A and C->A. note the link module contains only link sets, not actual links. the links are stored in the source modules, i.e., Modules B and C.
Just to be safe, I would also go to File > Module Properties... select Linksets tab and set linksets in each of B and C to A through link Module L. Make mandatory and Only allow outgoing links... at the bottom.
Now we are ready to create objects in A (Insert > Object). Create some requirement text in the "Object Text" attribute or any other attributes that you want to appear in the other modules.
go to B and create an object. Link > Start Link go to the Object in A you want to link to and select Link > Make Link from Start. (It may ask the first time if you want to create a link set, just say Yes.) a little orange outgoing, and yellow incoming triangle will appear on each corresponding object.
finally, in B Analysis > Wizard... choose Out-links, DOORS links only; Next> (since we only have one anyway) choose All (formal) modules and All (Link) Modules; Next>
(choose the attributes you want to display from the other module) Next> (make sure Recursive analysis is not checked) and Finish.
This will create another column in Module B with the attributes you want to display from Module A.
You can now go to View > Save As... and give the view a name and at any time, see the linked information from Module B.
The only DXL that was written here was the DXL you wrote when you ran the Wizard.
WOW! A whole free training module in how to use DOORS!
You will want to investigate the 'Link by Attribute' tool under the Link - Advanced menu. This is on DOORS 9.6.1.10, though most 9.x should have the same.
You will be able to create links between two modules, matching up a particular attribute- and then repeating the process for each subsequent module you need to link to.

Rally print stories with parent feature name in the card generated

I've used Joel Krooswyk's Print All Backlog Story Cards solution for printing all stories in a backlog.
What I'd like to do is to extend this to have each card print the name of the parent feature that the card belongs to so I can print them all up and lay them on a table for a collaborative estimation session.
The issue is, I'm having trouble finding how to do it.
A snippet of his code in question:
queryArray[0] = {
key: CARD_TYPE,
type: 'hierarchicalrequirement',
query: '((Iteration.Name = "") AND (Release.Name = ""))',
fetch: 'Name,Iteration,Owner,FormattedID,PlanEstimate,ObjectID,Description,UserName',
order: 'Rank'
};
I can't seem to find the element to fetch!
Parent was listed on an example queries page(intended for use in the browser query functionality), with Parent.Name containing the actual text but so that hasn't worked - trying to find a reference that is clear about it seems to be eluding me.
I've looked at the type definition located at:
https://rally1.rallydev.com/slm/webservice/v2.0/typedefinition/?fetch=ObjectID&pagesize=100&pretty=true
Going to the hierarchical requirement's type definition from that page indicates it has a Parent field in one form or another.
I'm not even sure that that one will solve what I'm looking at.
A bit stuck, and I'm not sure what I'm trying to do is even possible with the hierarchical requirement object type.
Note: I assume even if I do find it I'll need to add some code to deal parentless stories- not worried about that though, that's easy enough to deal with once I find the actual value.
Many thanks to anyone who can help :)
I modified Joel's app to include PI/Feature's FormattedID to the cards when a story has a parent PI/Feature.
You may see the code in this github repo.
Parent field of a user story references another user story.
If you want to read a parent portfolio item of a user story, which is a Feature object, use Feature attribute or PortfolioItem attribute. Both will work:
if (data[i].PortfolioItem) {
//feature = data[i].PortfolioItem.FormattedID; //also works
//feature = data[i].Feature.Name; //also works
feature = data[i].Feature.FormattedID;
} else {
feature = "";
}
as long as the version of API is set in the code to 1.37 or above (up to 1.43).
PrintStoryCards app is AppSDK1 app.
1.33 is the latest version of AppSDK1.x
1.29, which the app is using is not aware of PortfoilioItems.
PortfolioItem was introduced in Rally in WS API version 1.37.
See API versioning section in the WS API documentation .
If you want to access Portfolio Items, or other features introduced in later versions of WS API up to 1.43 this syntax will allow it.
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43"></script>
This has to be used with caution. One thing that definitely will break is around calculations of timebox start and end dates. That's why many legacy Rally App Catalog apps are still at 1.29.
This is due to changes in API Version 1.30.
Note that this method of setting a more advanced version of WS API for AppSDK1 does not work with v2.0 of WS API.
You should be able to add PortfolioItem to your fetch. Parent is the field used if the parent is a story. PortfolioItem is the field used if the parent is a Feature (or whatever your lowest level PI is).
Then in the results you can just get it like this:
var featureName = (story.PortfolioItem && story.PortfolioItem.Name) || 'None';

Kentico Ecommerce: getting top selling categories

I am using Kentico 7.0, ecommerce version.
I would like to create a sidebar menu that shows the eshop's top selling product categories. I am a kentico newbie so I am looking around for the correct terminology/guidance so that I can dig deeper.
The ideal approach in my opinion would be to be able to add a field on categories, which is used to filter categories for the menu. This way I can either have some kind of job that updates the fields automatically based on sales, OR provide a manual override for an admin to specify whether a category will show up on the menu. Of course some kind of weight would also be needed to specify menu item ordering.
Which way should I look?
HAve you tried using the "Top N products by sales" web part that is available? you can configure from which part of the content tree (products) it should pull the data - in the Path property you can use also a path expression or macro that is resolved dynamically so the web part can display different products in different sections.
There are many ways to code for Kentico. I personally find the API is a bit clunky and on quite a few occasions I was surprised that a method didn't exist requiring extra calls to get the required results. I do use the Kentico API more when putting data in to Kentico. Pulling it out I use the following.
STORED PROC
Write a SQL stored procedure to get the top X categories - GetTop5Categories.
Look at the COM_* tables, specifically COM_OrderItem, linking OrderItemSKUID back to COM_SKU (or View_COM_SKU_Joined if you need to get to the IA).
This will get you the top selling products with a group by, a count, a top X and an order by.
Then you can link to other tables such as CMS_Category or CMS_Document (depending on how you setup your categories). The bonus of this is that procs are compiled, you do all your data manipulation there (it's what MSSQL specialises in!) and you only send back what you need to in the result set.
DOMAIN (leveraging EF)
I usually create a separate class library project myproject.domain and put an Entity Framework edmx in there mapped back to the Kentico DB. Add the proc to the EDMX, then create a Function Import MyProject_GetTop5Categories from your newly imported proc.
WEB
add a reference to the domain project from your web project, and a 'using at the top of the codebehind of the control.
using myproject.domain;
then in Page_Load for the control:
...
if(!IsPostBack)
{
var entities = new MyProjectModelContainer();
var list = entities.MyProject_GetTop5Categories().ToList();
StringBuilder sb = new StringBuilder("<ul>");
foreach(var category in list)
{
sb.Append("<li><a href='"+category.Link+"'>" + category.Name + "</a></li>");
}
sb.Append("<ul>");
listPlaceHolder = sb.ToString();
}
handwritten so probably a typo or two in there :)
HTH

How to update the values of Magento products using installer/update scripts and Magento abstractions?

I added a custom eav attribute to my Magento application product entity using an installer script (Basically, following the procedure described here: Installing Custom Attributes with Your Module). Now, I want to use an update script to change (populate) the values of this attribute for each product according to some criteria (based on the product category). The script I attempted to use was essentially like this:
$attributeValues = array(...) // Map from $productId to the desired $value
$product = Mage::getModel('catalog/product');
foreach($attributeValues as $productId=>$value){
$product->load($productId)->setMyAttribute($value);
$product->save();
}
My questions would then be: Is it ok to use this level of abstraction (Mage::getModel('catalog/product') and its methods) in update scripts? If it isn't, how would you recommend to change these attribute values using update scripts (without requiring sql)?
The script I used (until now) has not worked and failed with the error:
Call to a member function getStoreIds() on a non-object
in a magento core file.
I don't know if this error is a Magento bug or is a problem with how I'm using the update scripts.
I'm using Magento 1.4.0.1
Data update scripts are the way to go
Simply use a data upgrade script for this. This is a script placed in the data folder instead of the sql folder. Those scripts run later then the database structure updates, and allow access to more functionality.
Example file names:
app/code/local/My/Module/data/your_setup/data-install-0.1.0.php
app/code/local/My/Module/data/your_setup/data-upgrade-0.1.0-0.2.0.php
This is already available in Magento 1.4.
Try adding Mage::app()->setUpdateMode(false) in your sql upgrade script. e.g.
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');;
$installer->startSetup();
Mage::app()->setUpdateMode(false);
Mage::app()->setCurrentStore('your_store_code_here');
If you look in Mage::app()->getStore() you will see the following snippet that returns an incorrect store which is required for saving a product.
if (!Mage::isInstalled() || $this->getUpdateMode()) {
return $this->_getDefaultStore();
}

How to Customise Magento Enterprise Customer Segments?

Do I
1) overide all Enterprise/CustomerSegment
then slot in the classes I need to add my own conditions and classes for models to build the DB queries
2) 1) seems bulky, how would I just add my new condition classes into a local folder?
The solution is to override only the models, and leave the block, controller using Enterprise_CustomerSegment module.
These files would be required to update the CustomerSegment module to add a standing order report:
CustomModule/CustomerSegment/etc/config.xml (with all the model 's)
CustomModule/CustomerSegment/Model/Condition/Combine/Abstract.php
(this may not need to be overridden)
CustomModule/CustomerSegment/Model/Segment/Condition/Combine/Root.php
CustomModule/CustomerSegment/Model/Segment/Condition/Standingorder/Frequency.php
CustomModule/CustomerSegment/Model/Segment/Condition/Combine.php
CustomModule/CustomerSegment/Model/Segment/Condition/Standingorder.php
CustomModule/CustomerSegment/Model/Segment.php
(this may not need to be overridden)