Search Results

Search found 10804 results on 433 pages for 'attribute keys'.

Page 179/433 | < Previous Page | 175 176 177 178 179 180 181 182 183 184 185 186  | Next Page >

  • Schema for element with Attributes and Child nodes

    - by Matthew
    I am trying to write xsd type schema for an element that has a custom type to include addition attributes to extend a base type. I am running into trouble getting the syntax right. <xs:element name="graphs"> <xs:complexType> <xs:sequence> <xs:element name="graph" minOccurs="1" maxOccurs="unbounded" type="graphType"> <!-- child elements --> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="graphType"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="title" type="xs:string"/> <xs:attribute name="type" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> I thought this would be something very common, but having read many tuts and forums, I cant seem to find an answer that works for me.

    Read the article

  • Dynamically generate client-side HTML form control using JavaScript and server-side Python code in Google App Engine

    - by gisc
    I have the following client-side front-end HTML using Jinja2 template engine: {% for record in result %} <textarea name="remark">{{ record.remark }}</textarea> <input type="submit" name="approve" value="Approve" /> {% endfor %} Thus the HTML may show more than 1 set of textarea and submit button. The back-end Python code retrieves a variable number of records from a gql query using the model, and pass this to the Jinja2 template in result. When a submit button is clicked, it triggers the post method to update the record: def post(self): if self.request.get('approve'): updated_remark = self.request.get('remark') record.remark = db.Text(updated_remark) record.put() However, in some instances, the record updated is NOT the one that correspond to the submit button clicked (eg if a user clicks on record 1 submit, record 2 remark gets updated, but not record 1). I gather that this is due to the duplicate attribute name remark. I can possibly use JavaScript/jQuery to generate different attribute names. The question is, how do I code the back-end Python to get the (variable number of) names generated by the JavaScript? Thanks.

    Read the article

  • Bootstrap - Typehead on multiple inputs

    - by Clem
    I have two text intputs, both have to run an autocompletion. The site is using Bootstrap, and the « typeahead » component. I have this HTML : <input type="text" class="js_typeahead" data-role="artist" /> <input type="text" class="js_typeahead" data-role="location" /> I'm using the « data-role » attribute (that is sent to the Ajax controller as a $_POST index), in order to determine what kind of data has to be retrieved from the database. The Javascript goes this way : var myTypeahead = $('input.js_typeahead').typeahead({ source: function(query, process){ var data_role; data_role = myTypeahead.attr('data-role'); return $.post('/ajax/typeahead', { query:query,data_role:data_role },function(data){ return process(data.options); }); } }); With PHP, I check what $_POST['data-role'] contains, an run the MySQL query (in this case, a query either on a list of Artists, or a list of Locations). But the problem is the second "typeahead" returns the same values than the first one (list of Artists). I assume it's because the listener is attached to the object « myTypeahead », and this way the "data-role" attribute which is used, will always be the same. I think I could fix it by using something like : data_role = $(this).attr('data-role'); But of course this doesn't work, as it's a different scope. Maybe I'm doing it all wrong, but at least maybe you people could give me a hint. Sorry if this has already been discussed, I actually searched but without success. Thanks in advance, Clem (from France, sorry for my english)

    Read the article

  • Link error for user defined class type template parameter

    - by isurulucky
    Hi, I implemented a Simple STL map in C++. Factored out the comparison as a type as I was instructed to, then implemented the comparison as shown below: template <typename T> int KeyCompare<T>::operator () (T tKey1, T tKey2) { if(tKey1 < tKey2) return -1; else if(tKey1 > tKey2) return 1; else return 0; } here, tKey1 and tKet2 are the two keys I'm comparing. This worked well for all the basic data types and string. I added a template specialization to compare keys of a user defined type named Test and added a specialization as follows: int KeyCompare<Test>::operator () (Test tKey1, Test tKey2) { if(tKey1.a < tKey2.a) return -1; else if(tKey1.a > tKey2.a) return 1; else return 0; } when I run this, I get a linking error saying SimpleMap.obj : error LNK2005: "public: int __thiscall KeyCompare::operator()(class Test,class Test)" (??R?$KeyCompare@VTest@@@@QAEHVTest@@0@Z) already defined in MapTest.obj SimpleMap.obj : error LNK2005: "public: __thiscall KeyCompare::~KeyCompare(void)" (??1?$KeyCompare@VTest@@@@QAE@XZ) already defined in MapTest.obj SimpleMap.obj : error LNK2005: "public: __thiscall KeyCompare::KeyCompare(void)" (??0?$KeyCompare@VTester@@@@QAE@XZ) already defined in MapTest.obj MapTest.cpp is the test harness class in which I wrote the test case. I have used include guards as well, to stop multiple inclusions. Any idea what the matter is?? Thank you very much!!

    Read the article

  • ASP MVC: E-mail Verification (Encrypting the activation link)

    - by wh0emPah
    Okay i'm a little bit stuck on how to solve this problem. When a user registers. I want to send him a link so that he can verify hes email address. But i have troubles generating the link. I've already written the controller to accept the links with the correct keys. i only have no idea on how to generate the activation keys. So when the user registers i'll send him a link by mail like this: Your activation link is : http://site.com/user/verify?key=keyhere Now i have created this method (called by the controller/action) to handle the key in the link: public string Verify(string value) { String email = Decrypt(value); user u = gebRep.GetUsers().WithEmail(email).SingleOrDefault(); if (u != null) { u.emailValid = true; userReppository.Save(); } return "Invallid validation value!"; } Now my problem is I have no idea on how to encrypt and decrypt the email into some sort of key (url friendly) So i can mail it with the link and can use it to verify the email. I need some kind of (not to complicated but secure) way to encrypt the email into a urlfriendly key. Tyvm

    Read the article

  • Trying to output a list using class

    - by captain morgan
    Am trying to get the moving average of a price..but i keep getting an attribute error in my Moving_Average class. ('Moving_Average' object has no attribute 'days'). Here is what I have: class Moving_Average: def calculation(self, alist:list,days:int): m = self.days prices = alist[1::2] average = [0]* len(prices) signal = ['']* len(prices) for m in range(0,len(prices)-days+1): average[m+2] = sum(prices[m:m+days])/days if prices[m+2] < average[m+2]: signal[m+2]='SELL' elif prices[m+2] > average[m+2] and prices[m+1] < average[m+1]: signal[m+2]='BUY' else: signal[m+2] ='' return average,signal def print_report(symbol:str,strategy:str): print('SYMBOL: ', symbol) print('STRATEGY: ', strategy) print('Date Closing Strategy Signal') def user(): strategy = ''' Which of the following strategy would you like to use? * Simple Moving Average [S] * Directional Indicator[D] Please enter your choice: ''' if signal_strategy in 'Ss': days = input('Please enter the number of days for the average') days = int(days) strategy = 'Simple Moving Average {}-days'.format(str(days)) m = Moving_Average() ma = m.calculation(gg, days) print(ma) gg is an list that contains date and prices. [2013-10-01,60,2013-10-02,60] The output is supposed to look like: Date Price Average Signal 2013-10-01 60.0 2013-10-02 60.0 60.00 BUY

    Read the article

  • Adding integer value to a list from XML file

    - by Pramodh
    I've an Xml file like <SampleFile> <Data> <Element Val="8" /> <Element Val="10" /> <Element Val="12" /> <Element Val="14" /> <Element Val="16" /> <Element Val="9" /> <Element Val="11" /> <Element Val="13" /> <Element Val="15" /> <Element Val="17" /> </Data> </SampleFile> i need to read the attribute value of" Val" and convert it to Int32 , then sort and then add to the list now i'm using like: List<Int32> lst = (XDocument.Load("\\Sample.xml").Descendants("Element").Select(l_Temp => l_Temp.Attribute("Val").Value.ToString()).Cast<Int32>().OrderBy(nTemp => nTemp)).ToList(); but its not working properly please give me a better solution

    Read the article

  • Trigger JavaScript action after Datatable is loaded

    - by perissf
    In a JSF 2.1 + PrimeFaces 3.2 web application, I need to trigger a JavaScript function after a p:dataTable is loaded. I know that there is no such event in this component, so I have to find a workaround. In order to better understand the scenario, on page load the dataTable is not rendered. It is rendered after a successful login: <p:commandButton value="Login" update=":aComponentHoldingMyDataTable" action="#{loginBean.login}" oncomplete="handleLoginRequest(xhr, status, args)"/> As you can see from the above code, I have a JavaScript hook after the successful login, if it can be of any help. Immediately after the oncomplete action has finished, the update attribute renders the dataTable: <p:dataTable var="person" value="#{myBean.lazyModel}" rendered="#{p:userPrincipal() != null}" /> After the datatable is loaded, I need to run a JavaScript function on each row item, in order to subscribe to a cometD topic. In theory I could use the oncomplete attribute of the login Button for triggering a property from myBean in order to retrieve once again the values to be displayed in the dataTable, but it doesn't seem very elegant. The JavaScript function should do something with the rowKey of each row of the dataTable: function javaScriptFunctionToBeTriggered(rowKey) { // do something }

    Read the article

  • Forwarding keypresses in GTK

    - by dguaraglia
    I'm writing a bit of code for a Gedit plugin. I'm using Python and the interface (obviously) is GTK. So, the issue I'm having is quite simple: I have a search box (a gtk.Entry) and right below I have a results box (a gtk.TreeView). Right after you type something in the search box you are presented a bunch of results, and I would like the user to be able to press the Up/Down keys to select one, Enter to choose it, and be done. Thing is, I can't seem to find a way to forward the Up/Down keypress to the TreeView. Currently I have this piece of code: def __onSearchKeyPress(self, widget, event): """ Forward up and down keys to the tree. """ if event.keyval in [gtk.keysyms.Up, gtk.keysyms.Down]: print "pressed up or down" e = gtk.gdk.Event(gtk.gdk.KEY_PRESS) e.keyval = event.keyval e.window = self.browser.window e.send_event = True self.browser.emit("key-press-event", e) return True I can clearly see I'm receiving the right kind of event, but the event I'm sending gets ignored by the TreeView. Any ideas? Thanks in advance people.

    Read the article

  • Blocking error in celery

    - by dmitry
    I have no idea what's this. Python 2.7 + django-1.5.1 + httpd + rabbitmq + django-celery==3.0.17 Tasks are not executed because of some error. Below is celery's log. Maybe someone has faced it before. [2013-06-24 17:10:03,792: CRITICAL/MainProcess] Can't decode message body: AttributeError("'JoinInfo' object has no attribute '__dict__'",) (type:u'application/x-python-serialize' encoding:u'binary' raw:'\'\\x80\\x02}q\\x01(U\\x07expiresq\\x02NU\\x03utcq\\x03\\x88U\\x04argsq\\x04cdjango.contrib.auth.models\\nUser\\nq\\x05)\\x81q\\x06}q\\x07(U\\x08usernameq\\x08X\\x19\\x00\\x00\\[email protected]\\nfirst_nameq\\tX\\x05\\x00\\x00\\x00BibbyU\\tlast_nameq\\nX\\x08\\x00\\x00\\x00OffshoreU\\r_client_cacheq\\x0bccopy_reg\\n_reconstructor\\nq\\x0ccbongoregistration.models\\nClient\\nq\\rc__builtin__\\nobject\\nq\\x0eN\\x87Rq\\x0f}q\\x10(h\\nX\\x08\\x00\\x00\\x00OffshoreU\\x1bpurchase_confirmation_emailq\\x11X\\x1f\\x00\\x00\\[email protected]\\x1dpurchase_confirmation_email_1q\\x12X!\\x00\\x00\\[email protected]\\x06_stateq\\x13cdjango.db.models.base\\nModelState\\nq\\x14)\\x81q\\x15}q\\x16(U\\x06addingq\\x17\\x89U\\x02dbq\\x18U\\x07defaultq\\x19ubU\\x0buser_ptr_idq\\x1aJ\\xb4\\xa2\\x03\\x00U\\x08is_staffq\\x1b\\x89U\\x08postcodeq\\x1cX\\x08\\x00\\x00\\x00AB11 5BSU\\x0cdegree_limitq\\x1dK\\x06U\\x07messageq\\x1eX\\xd1E\\x00\\x00<table id="container" style="margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;" cellspacing="0" cellpadding="0"... (22911b)'') Traceback (most recent call last): File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/messaging.py", line 556, in _receive_callback decoded = None if on_m else message.decode() File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/transport/base.py", line 147, in decode self.content_encoding, accept=self.accept) File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/serialization.py", line 187, in decode return decode(data) File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/serialization.py", line 74, in pickle_loads return load(BytesIO(s)) AttributeError: 'JoinInfo' object has no attribute '__dict__'

    Read the article

  • Refactoring code/consolidating functions (e.g. nested for-loop order)

    - by bmay2
    Just a little background: I'm making a program where a user inputs a skeleton text, two numbers (lower and upper limit), and a list of words. The outputs are a series of modifications on the skeleton text. Sample inputs: text = "Player # likes @." (replace # with inputted integers and @ with words in list) lower = 1 upper = 3 list = "apples, bananas, oranges" The user can choose to iterate over numbers first: Player 1 likes apples. Player 2 likes apples. Player 3 likes apples. Or words first: Player 1 likes apples. Player 1 likes bananas. Player 1 likes oranges. I chose to split these two methods of outputs by creating a different type of dictionary based on either number keys (integers inputted by the user) or word keys (from words in the inputted list) and then later iterating over the values in the dictionary. Here are the two types of dictionary creation: def numkey(dict): # {1: ['Player 1 likes apples', 'Player 1 likes...' ] } text, lower, upper, list = input_sort(dict) d = {} for num in range(lower,upper+1): l = [] for i in list: l.append(text.replace('#', str(num)).replace('@', i)) d[num] = l return d def wordkey(dict): # {'apples': ['Player 1 likes apples', 'Player 2 likes apples'..] } text, lower, upper, list = input_sort(dict) d = {} for i in list: l = [] for num in range(lower,upper+1): l.append(text.replace('#', str(num)).replace('@', i)) d[i] = l return d It's fine that I have two separate functions for creating different types of dictionaries but I see a lot of repetition between the two. Is there any way I could make one dictionary function and pass in different values to it that would change the order of the nested for loops to create the specific {key : value} pairs I'm looking for? I'm not sure how this would be done. Is there anything related to functional programming or other paradigms that might help with this? The question is a little abstract and more stylistic/design-oriented than anything.

    Read the article

  • gcc -finline-functions behaviour?

    - by user176168
    I'm using gcc with the -finline-functions optimization for release builds. In order to combat code bloat because I work on an embedded system I want to say don't inline particular functions. The obvious way to do this would be through function attributes ie attribute(noinline). The problem is this doesn't seem to work when I switch on the global -finline-functions optimisation which is part of the -O3 switch. It also has something to do with it being templated as a non templated version of the same function doesn't get inlined which is as expected. Has anybody any idea of how to control inlining when this global switch is on? Here's the code: #include <cstdlib> #include <iostream> using namespace std; class Base { public: template<typename _Type_> static _Type_ fooT( _Type_ x, _Type_ y ) __attribute__ (( noinline )); }; template<typename _Type_> _Type_ Base::fooT( _Type_ x, _Type_ y ) { asm(""); return x + y; } int main(int argc, char *argv[]) { int test = Base::fooT( 1, 2 ); printf( "test = %d\n", test ); system("PAUSE"); return EXIT_SUCCESS; }

    Read the article

  • DB Design to store custom fields for a table

    - by Fazal
    Hi All, this question came up based on the responses I got for the question http://stackoverflow.com/questions/2785033/getting-wierd-issue-with-to-number-function-in-oracle As everyone suggested that storing Numeric values in VARCHAR2 columns is not a good practice (which I totally agree with), I am wondering about a basic Design choice our team has made and whether there are better way to design. Problem Statement : We Have many tables where we want to give certain number of custom fields. The number of required custom fields is known, but what kind of attribute is mapped to the column is available to the user E.g. I am putting down a hypothetical scenario below Say you have a laptop which stores 50 attribute values for every laptop record. Each laptop attributes are created by the some admin who creates the laptop. A user created a laptop product lets say lap1 with attributes String, String, numeric, numeric, String Second user created laptop lap2 with attributes String,numeric,String,String,numeric Currently there data in our design gets persisted as following Laptop Table Id Name field1 field2 field3 field4 field5 1 lap1 lappy lappy 12 13 lappy 2 lap2 lappy2 13 lappy2 lapp2 12 This example kind of simulates our requirement and our design Now here if somebody is lookinup records for lap2 table doing a comparison on field2, We need to apply TO_NUMBER. select * from laptop where name='lap2' and TO_NUMBER(field2) < 15 TO_NUMBER fails in some cases when query plan decides to first apply to_number instead of the other filter. QUESTION Is this a valid design? What are the other alternative ways to solve this problem One of our team mates suggested creating tables on the fly for such cases. Is that a good idea How do popular ORM tools give custom fields or flex fields handling? I hope I was able to make sense in the question. Sorry for such a long text.. This causes us to use TO_NUMBER when queryio

    Read the article

  • How to reference other documents in a couchDB view (joining like functionality)

    - by Surfrdan
    We have a CouchDB representation of an XML database which we use to power a javascript based frontend for manipulating the XML documents. The basic structure is a simple 3 level hierachy. i.e. A - B - C A: Parent doucument (type A) B: any number of child documents of parent type A C: any number of child documents of parent type B We represent these 3 document types in CouchDB with a 'type' attribute: e.g. { "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"A", "label":"Top Level A document", "logicalMap":{ "issues":{ "1":{ "URL":"http://hdl.handle.net/10107/434-0", "FILE":"llgc-id:434" }, "2":{ "URL":"http://hdl.handle.net/10107/467-0", "FILE":"llgc-id:467" etc... } } } } { "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"B", "label":"a B document", } What I want to do is produce a view which returns documents just like the A type but includes the label attribute from the B document within the logicalMap list e.g. { "_id":"llgc-id:433", "_rev":"1-3760f3e01d7752a7508b047e0d094301", "type":"A", "label":"Top Level A document", "logicalMap":{ "issues":{ "1":{ "URL":"http://hdl.handle.net/10107/434-0", "FILE":"llgc-id:434", "LABEL":"a B document" }, "2":{ "URL":"http://hdl.handle.net/10107/467-0", "FILE":"llgc-id:467", "LABEL":"another B document" etc... } } } } I'm struggling to get my head around the best way to perform this. It looks like it should be fairly simple though!

    Read the article

  • How to filter node list based on the contents of another node list

    - by ~otakuj462
    Hi, I'd like to use XSLT to filter a node list based on the contents of another node list. Specifically, I'd like to filter a node list such that elements with identical id attributes are eliminated from the resulting node list. Priority should be given to one of the two node lists. The way I originally imagined implementing this was to do something like this: <xsl:variable name="filteredList1" select="$list1[not($list2[@id_from_list1 = @id_from_list2])]"/> The problem is that the context node changes in the predicate for $list2, so I don't have access to attribute @id_from_list1. Due to these scoping constraints, it's not clear to me how I would be able to refer to an attribute from the outer node list using nested predicates in this fashion. To get around the issue of the context node, I've tried to create a solution involving a for-each loop, like the following: <xsl:variable name="filteredList1"> <xsl:for-each select="$list1"> <xsl:variable name="id_from_list1" select="@id_from_list1"/> <xsl:if test="not($list2[@id_from_list2 = $id_from_list1])"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> </xsl:variable> But this doesn't work correctly. It's also not clear to me how it fails... Using the above technique, filteredList1 has a length of 1, but appears to be empty. It's strange behaviour, and anyhow, I feel there must be a more elegant approach. I'd appreciate any guidance anyone can offer. Thanks.

    Read the article

  • How can I call `update_attribute` for a list item in rails then actually update the html using jquery?

    - by Patrick Connor
    I want my users to be able to mark one or more items from an index view as "Active" or "Inactive" using a link. The text for the link should be state aware - so it might default to "Mark as Active" if the corresponding attribute was false or null, and "Mark as Inactive" if true. Once the user clicks the link and the attribute is updated in the controller, the link-text should update based on the new state. I am WAY off here, but this is a small sample of the code I have been trying... CONTROLLER ... respond_to :html, :js ... def update @item = Item.find(params[:id]) if @item.update_attributes(params[:item]) #Not sure of how to respond to .js here end end ... update.js.erb #how do I identify which element to update? $('#item[13456]').html("State aware text for link_to") VIEW - for item in @items = item.name = link_to "Mark as Active", item_path(item), :method => :put, :remote => true. :id => "item[#{item.id}]" I am happy to read any APIs, blogs, tutorials, etc. I just can't seem to get my hands/mind around this task. Any help or guidance is greatly appreciated!

    Read the article

  • Which class should store the lookup table?

    - by max
    The world contains agents at different locations, with only a single agent at any location. Each agent knows where he's at, but I also need to quickly check if there's an agent at a given location. Hence, I also maintain a map from locations to agents. I have a problem deciding where this map belongs to: class World, class Agent (as a class attribute) or elsewhere. In the following I put the lookup table, agent_locations, in class World. But now agents have to call world.update_agent_location every time they move. This is very annoying; what if I decide later to track other things about the agents, apart from their locations - would I need to add calls back to the world object all across the Agent code? class World: def __init__(self, n_agents): # ... self.agents = {} self.agent_locations = {} for id in range(n_agents): x, y = self.find_location() agent = Agent(self,x,y) self.agents.append(agent) self.agent_locations[x,y] = agent def update_agent_location(self, agent, x, y): del self.agent_locations[agent.x, agent.y] self.agent_locations[x, y] = agent def update(self): # next step in the simulation for agent in self.agents: agent.update() # next step for this agent # ... class Agent: def __init__(self, world, x, y): self.world = world self.x, self.y = x, y def move(self, x1, y1): self.world.update_agent_location(self, x1, y1) self.x, self.y = x1, y1 def update(): # find a good location that is not occupied and move there for x, y in self.valid_locations(): if not self.location_is_good(x, y): continue if self.world.agent_locations[x, y]: # location occupied continue self.move(x, y) I can instead put agent_locations in class Agent as a class attribute. But that only works when I have a single World object. If I later decide to instantiate multiple World objects, the lookup tables would need to be world-specific. I am sure there's a better solution... EDIT: I added a few lines to the code to show how agent_locations is used. Note that it's only used from inside Agent objects, but I don't know if that would remain the case forever.

    Read the article

  • SQLAlchemy Mapping problem

    - by asdvalkn
    Dear Everyone, I am trying to sqlalchemy to correctly map my data. Note that a unified group is basically a group of groups. (One unifiedGroup maps to many groups but each group can only map to one ug). So basically this is the definition of my unifiedGroups: CREATE TABLE `unifiedGroups` ( `ugID` INT AUTO_INCREMENT, `gID` INT NOT NULL, PRIMARY KEY(`ugID`, `gID`), KEY( `gID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; Note that each row is a ugID, gID tuple. ( I do not know before hand how many gID is per ugID so this is probably the most sensible and simplest method). Definition for my UnifiedGroup class class UnifiedGroup(object): """UnifiedProduct behaves very much like a group """ def __init__(self, ugID): self.ugID=ugID #Added by mapping self.groups=False def __str__(self): return '<%s:%s>' % (self.ugID, ','.join( [g for g in self.groups])) These are my mapping tables: tb_groupsInfo = Table( 'groupsInfo', metadata, Column('gID', Integer, primary_key=True), Column('gName', String(128)), ) tb_unifiedGroups = Table( 'unifiedGroups', metadata, Column('ugID', Integer, primary_key=True), Column('gID', Integer, ForeignKey('groupsInfo.gID')), ) My mapper maps in the following manner: mapper( UnifiedGroup, tb_unifiedGroups, properties={ 'groups': relation( Group, backref='unifiedGroup') }) However, when I tried to do groupInstance.unifiedGroup, I am getting an empty list [], while groupInstance.unifiedGroup.groups returns me an error: AttributeError: 'InstrumentedList' object has no attribute 'groups' Traceback (most recent call last): File "Mapping.py", line 119, in <module> print p.group.unifiedGroup.groups AttributeError: 'InstrumentedList' object has no attribute 'groups' What is wrong?

    Read the article

  • Rails - Scalable calculation model

    - by H O
    I currently have a calculation structure in my rails app that has models metric, operand and operation_type. Presently, the metric model has many operands, and can perform calculations based on the operation_type (e.g. sum, multiply, etc.), and each operand is defined as being right or left (i.e. so that if the operation is division, the numerator and denominator can be identified). Presently, an operand is always an attribute of some model, e.g. @customer.sales.selling_price.sum. In order to make this scalable, in need to allow an operand to be either an attribute of some kind, or the results of a previous operation, i.e. an operand can be a metric. I have included a diagram of how my models currently look: Can anyone assist me with the most elegant way of allowing an operand to be an actual operand, or another metric? Thanks! EDIT: It seems based on the only answer so far that perhaps polymorphic associations are the way to go on this, but the answer is so brief I have no idea how they could be used in this way - can anyone elaborate? EDIT 2: OK, I think I'm getting somewhere - essentially i presently have a metric, which has_many operands, and an operand has_many metrics. I need a polymorphic self join, where a metric can also have many metrics - do I need to call this something else, perhaps calculated_metrics, so that the metric model can use itself? That would leave me with a situation where a metric has_many operands, and a metric has many calculated_metrics.

    Read the article

  • Creating a dynamic two-column iOS spinning wheel with HTML/Javascript

    - by JSW189
    I am trying to create a dynamic two-column spinning wheel for iOS Safari using this HTML/Javascript wheel. However, I am having trouble getting the value of the first column to change the results of the second column. I have tried using an if statement to get the value of the first variable (var beverage) and add the value of the second column correspondingly. Does anybody know what I am doing wrong/if there is a better approach? function openBirthDate() { var beverage = { 1:'Coffee', 2:'Soda' }; //THIS IS WHERE I'M HAVING TROUBLE var results = SpinningWheel.getSelectedValues(); if (results.values === 1) { var company = { 1:'Starbucks', 2:'Dunkin Donuts' }; } else { var company = { 1:'Coke', 2:'Pepsi' }; } var size = { 1:'Tall', 2:'Grande', 3:'Venti' }; SpinningWheel.addSlot(type, '', 1); SpinningWheel.addSlot(company, '', 1); SpinningWheel.addSlot(size, '', 1); SpinningWheel.setCancelAction(cancel); SpinningWheel.setDoneAction(done); SpinningWheel.open(); } function done() { var results = SpinningWheel.getSelectedValues(); document.getElementById('result').innerHTML = 'values: ' + results.values.join(' ') + '<br />keys: ' + results.keys.join(', '); } function cancel() { document.getElementById('result').innerHTML = 'cancelled!'; } window.addEventListener('load', function(){ setTimeout(function(){ window.scrollTo(0,0); }, 100); }, true);

    Read the article

  • In perl, how can I call a method whose name I have in a string?

    - by Ryan Thompson
    I'm trying to write some abstract code for searching through a list of similar objects for the first one whose attributes match specific values. In order to do this, I need to call a bunch of accessor methods and check all their values one by one. I'd like to use an abstraction like this: sub verify_attribute { my ($object, $attribute_method, $wanted_value) = @_; if ( call_method($object, $attribute_method) ~~ $wanted_value ) { return 1; } else { return; } } Then I can loop through a hash whose keys are accessor method names and whose values are the values I'm looking for for those attributes. For example, if that hash is called %wanted, I might use code like this to find the object I want: my $found_object; FINDOBJ: foreach my $obj (@list_of_objects) { foreach my $accessor (keys %wanted) { next FINDOBJ unless verify_attribute($obj, $accessor, $wanted{$accessor}); } # All attrs verified $found_object = $obj; last FINDOBJ; } Of course, the only problem is that call_method does not exsit. Or does it? How can I call a method if I have a string containing its name? Or is there a better solution to this whole problem?

    Read the article

  • jQuery selectable() elements update values

    - by Josh
    Basically what I'm trying to do is update the value attribute of a hidden input field contained within the selected element when the selectable() UI stops running. If the element is selected, then the input's value should be the name attribute of that particular LI, whereas if the element is not selected, the value should be updated as empty. HTML Sample: <ul id="selector"> <li class="networkicon shr-digg" name="shr-digg"> <div></div> <label>Digg</label> <input type="hidden" value="" name="bookmark[]" /> </li> <li class="networkicon shr-reddit" name="shr-reddit"> <div></div> <label>Reddit</label> <input type="hidden" value="" name="bookmark[]" /> </li> <li class="networkicon shr-newsvine" name="shr-newsvine"> <div></div> <label>Newsvine</label> <input type="hidden" value="" name="bookmark[]" /> </li> </ul> Script Sample: $(function() { $("#selector").selectable({ filter: 'li', selected: function(event, ui) { $(".ui-selected").each(obj, function() { $(this).children('input').val($(this).attr('name')); }); }, unselected: function(event, ui) { $(".ui-selected").each(obj, function() { $(this).children('input').val(''); }); } }); });

    Read the article

  • How do I rescue a small portion of data from a SQL Server database backup?

    - by Greg
    I have a live database that had some data deleted from it and I need that data back. I have a very recent copy of that database that has already been restored on another machine. Unrelated changes have been made to the live database since the backup, so I do not want to wipe out the live database with a full restore. The data I need is small - just a dozen rows - but those dozen rows each have a couple rows from other tables with foreign keys to it, and those couple rows have god knows how many rows with foreign keys pointing to them, so it would be complicated to restore by hand. Ideally I'd be able to tell the backup copy of the database to select the dozen rows I need, and the transitive closure of everything that they depend on, and everything that depends on them, and export just that data, which I can then import into the live database without touching anything else. What's the best approach to take here? Thanks. Everyone has mentioned sp_generate_inserts. When using this, how do you prevent Identity columns from messing everything up? Do you just turn IDENTITY INSERT on?

    Read the article

  • LINQ to XML query attributes

    - by kb
    Hi using LINQ to XML, this is a sample of my XML <shows> <Show Code="456" Name="My Event Name"> <Event Code="2453" VenueCode="39" Date="2010-04-13 10:30:00" /> <Event Code="2454" VenueCode="39" Date="2010-04-13 13:30:00" /> <Event Code="2455" VenueCode="39" Date="2010-04-14 10:30:00" /> <Event Code="2456" VenueCode="39" Date="2010-04-14 13:30:00" /> <Event Code="2457" VenueCode="39" Date="2010-04-15 10:30:00" /> </Show> <Show... /> <Show... /> </shows> How do I return a list of the Dates for a specfic show? I am passing the show code ("456") in the querystring and want all the dates/times returned as a list. This is the code i have so far: XDocument xDoc = XDocument.Load("path to xml"); var feeds = from feed in xDoc.Descendants("Show") where feed.Attribute("Code").Equals("456") select new { EventDate = feed.Attribute("Date").Value }; foreach(var feed in feeds) { Response.Write(feed.EventDate + "<br />"); } But i get no results returned

    Read the article

  • Custom Header in ASIHTTPREQUEST

    - by Sharon Nathaniel
    Here is my problem. I am using ASIHTTPREQUEST to send request and get response. Now my need of the time is to upload a image,audio , video or docs via PUT method with a custom header . The header takes filename , filesize,sha256sum,username,mediatype,resume as parameters. Here is the code how I am doing that . -(void)uploadFile { NSString *resume =@"0"; NSUserDefaults *userCredentials =[NSUserDefaults standardUserDefaults]; NSString *userName =[userCredentials objectForKey:@"userName"]; NSArray *objects =[NSArray arrayWithObjects:selectedMediaType,delegate.fileName,userName,fileSize,fileSHA256Sum,resume, nil]; NSArray *keys =[NSArray arrayWithObjects:@"mediatype",@"file_name",@"usrname",@"filesize",@"sha256sum",@"resume", nil]; discSentValue =[NSDictionary dictionaryWithObjects:objects forKeys:keys]; NSURL *url = [NSURL URLWithString:@"http://briareos.code20.com/putmedia.php"]; uploadMedia = [ASIFormDataRequest requestWithURL:url]; [uploadMedia addRequestHeader:@"MEDIA_UPLOAD_CUSTOM_HEADER" value:[discSentValue JSONRepresentation]]; [uploadMedia setData:dataToUpload forKey:@"File"]; [uploadMedia setDelegate:self]; [uploadMedia setRequestMethod:@"PUT"]; [uploadMedia startAsynchronous]; } But the server is unable to recognize the header , it always returns "invalid header"

    Read the article

< Previous Page | 175 176 177 178 179 180 181 182 183 184 185 186  | Next Page >