Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'X' object has no attribute 'y'
#1
hi there,
i am new to python. i installed it in order to run a script that migrates Google Analytics to Piwik, a locally hosted open source solution using MYSQL/PHP. Anyways, I was able to get python running with Google API and can run the script but I run into the following Python error:

'Action' object has no attribute 'id_action_url'

Here is the code included in the file 'action.py'


import sql

TYPE_ACTION_URL = 1
TYPE_ACTION_NAME = 4

class action(object):
def __init__(self, path, title, internal_id):
self.path = path
self.titles = [title]
self.internal_id = internal_id
self.exported = False
self.pageviews = 0
self.timeleft = 0

def __repr__(self):
return str(self.titles)

def get_title(self):
for title in self.titles:
if title != None: return title
return ""

def export(self, base_path):
path = base_path + self.path
title = self.get_title()

type_url = ( path, self.get_hash(path), TYPE_ACTION_URL )

type_name = ( title, self.get_hash(title + path), TYPE_ACTION_NAME )

self.id_action_url = sql.insert_log_action(type_url)
self.id_action_name = sql.insert_log_action(type_name)

self.exported = True

def get_hash(self, value):
return abs(hash(value))

class ActionManager(object):
def __init__(self):
""" self.actions will be path -> Action mapper """
self.actions = {}
self.__counter = 0

def add_action(self, path, title):
if path in self.actions:
if not title in self.actions[path].titles:
self.actions[path].titles.append(title)
else:
self.actions[path] = Action(path, title, self.counter_next())

def __getitem__(self, path):
if path == None:
return None
if not path in self.actions:
self.actions[path] = Action(path, None, self.counter_next())
return self.actions[path]

def counter_next(self):
self.__counter += 1
return self.__counter

@property
def toExport(self):
""" Returns list of not yet exported actions"""
return filter(lambda x: self.actions[x].exported == False, self.actions)

def export(self, base_path):
for action in self.toExport:
self.actions[action].export(base_path)
Reply
#2
[quote='band_master' pid='278682' dateline='1335226686']
hi there,
i am new to python. i installed it in order to run a script that migrates Google Analytics to Piwik, a locally hosted open source solution using MYSQL/PHP. Anyways, I was able to get python running with Google API and can run the script but I run into the following Python error:

'Action' object has no attribute 'id_action_url'

Here is the code included in the file 'action.py'

I had to upload this to google docs since the forum would not preserve the tab spacing which is oh so critical for python. here is the link:

https://docs.google.com/document/d/1ScUu...2P0qg/edit
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: attribute of type 'NoneType' is not callable object chris0147 0 1,044 09-05-2014, 07:42 PM
Last Post: chris0147
  Module attribute problems. goqe 0 742 03-18-2013, 11:38 AM
Last Post: goqe
  [Guide] Object Serialization in Python manipulate 3 1,640 08-12-2011, 10:39 AM
Last Post: BreShiE
  Example of Object Oriented Programming nevets04 1 1,095 11-16-2009, 04:17 PM
Last Post: Fallen
  Calculator Using Object Oriented Programming nevets04 1 2,430 11-16-2009, 04:12 PM
Last Post: Fallen

Forum Jump:


Users browsing this thread: 1 Guest(s)